Troubles sending XML with HTTP

AitorEG
Member Posts: 342
Hi everyone,
I'm finding a lot of troubles develping a system for connecting our customers NAv 2013 with a courier company.
The first goal is to send an XMl file to the sercice, and get back another XML with the answer. I genrate the XML correctly, but when I start the development, I can see the next error:

"Cannot create the object...."
This is how I create the connection.
Trying different things, and having other issues with different objects, I realizes that the problem creating the node, could be because the received answer from the server is an error, so the received XML isn't as expected. S when I try to process the XML, I found the error.
So I decided to execute with the debugger, and I found this strange things:

As you can see, the RequestSteam and the ByteArray are not initialized. The byteArray is what I send in the HTTPRequest, so I think that the error may have something to do with this. Am I right?
I have to say, that I am using as example to follow the development for the "Electronic VAT Information under SII".
Thank you all for your help, I'm quite lost, so any help will be really welcome
I'm finding a lot of troubles develping a system for connecting our customers NAv 2013 with a courier company.
The first goal is to send an XMl file to the sercice, and get back another XML with the answer. I genrate the XML correctly, but when I start the development, I can see the next error:

"Cannot create the object...."
This is how I create the connection.
HttpWebRequest := WebRequest.Create(Uri.Uri('https://XXXXXXXXXXXXX/shipping/ship')); HttpWebRequest.Method := 'POST'; HttpWebRequest.ContentType := 'application/xml'; HttpWebRequest.Timeout := 120000; HttpWebRequest.UseDefaultCredentials(FALSE); XMLDocDotNet := XMLDocDotNet.XmlDocument; XMLDoc.save('C:\XML\convert\try.xml'); XMLDocDotNet.Load('C:\XML\convert\try.xml'); ByteArray := Encoding.UTF8.GetBytes('"xml_in=' + XMLDocDotNet.OuterXml + '"'); longitud := ByteArray.Length; HttpWebRequest.ContentLength := ByteArray.Length; IF NOT TryCreateRequestStream(HttpWebRequest,RequestStream) THEN BEGIN MESSAGE('Error al crear el request Stream'); EXIT; END; RequestStream.Write(ByteArray,0,ByteArray.Length); TryGetWebResponse(HttpWebRequest,HttpWebResponse); StatusCode := HttpWebResponse.StatusCode; StatusDescription := HttpWebResponse.StatusDescription; ResponseText := ReadHttpResponseAsText(HttpWebResponse); lPackingHeader.ProcessResponse(ResponseText,PackingNo);
Trying different things, and having other issues with different objects, I realizes that the problem creating the node, could be because the received answer from the server is an error, so the received XML isn't as expected. S when I try to process the XML, I found the error.
So I decided to execute with the debugger, and I found this strange things:

As you can see, the RequestSteam and the ByteArray are not initialized. The byteArray is what I send in the HTTPRequest, so I think that the error may have something to do with this. Am I right?
I have to say, that I am using as example to follow the development for the "Electronic VAT Information under SII".
Thank you all for your help, I'm quite lost, so any help will be really welcome
0
Answers
-
Hi AitorEG,
Can you translate the error message in English.
Also can you check CU1297 & CU1299 form NAV 2016 and try to construct your code in same way, that will be lot easier for you.
Thanks,
Manish Sinha1 -
sunmorningindia wrote: »Hi AitorEG,
Can you translate the error message in English.
Also can you check CU1297 & CU1299 form NAV 2016 and try to construct your code in same way, that will be lot easier for you.
Thanks,
Manish Sinha
Hi sun,
First of all,thank you very much. i am doing the development in a NAV2013 machine, so I didn't realize about those CUs you are talking about. Can I import those from another machien to my NAV2013 machine?
About the error message, it says this:
"Cannot create an instance of the next .NEt Framework object: Assembly System.Xml, Version=4.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089, type System.Xml.XmlNode"
Again, really appreciate your help
0 -
Hi everyone,
A little bit information about this problem. As I saide before, I am using as example to follow the development for the "Electronic VAT Information under SII". Inthe documentation for the VAt system, I've read that is needed the Cumulative Update 44 for Microsoft Dynamics NAV 2013 R2 (Build 48616). i am using the next version:
may this have something to do with me problem? I am quite obsessed about the RequestSteam and the ByteArray are not initialized, i do not see sense.
I am also having a llok to the Cu that @sunmorningindia told to me, but I think that I shloud resole this issue, because if not, it will be also giving me troubles when the VAT system starts to work officialy.
Thank you all for your help!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions