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.
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
Answers
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
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!