Using DOMDocument in HTTP Request
AitorEG
Member Posts: 342
Hy everuone. I'm trying to send a generated XML file to a web service. I am quite new doing thios, so I am using as example the "Electronic VAT Information under SII" Addon. The problem is that in this Addon, it uses for processing XML files the DotNet type, while I have generated the XML like an automation, as you can see in the parameter passed to the procedure.
For DOMDocument type, it can be used the Encoding.UTF8.GetBytes(XMLDoc.OuterXml); method, so it doesn't work. I think I should change the way I create the HTTP Request, but i am quite lost. Any hint will be appreciate.
Thank you all
For DOMDocument type, it can be used the Encoding.UTF8.GetBytes(XMLDoc.OuterXml); method, so it doesn't work. I think I should change the way I create the HTTP Request, but i am quite lost. Any hint will be appreciate.
Thank you all
PROCEDURE InvokeSoapRequest@1000000000(XMLDoc@1100000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument";PackingNo@1000000000 : Code[20]);
VAR
WebRequest@1100009 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.WebRequest";
HttpWebRequest@1100008 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebRequest";
RequestStream@1100005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Stream";
Encoding@1100011 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Text.Encoding";
ByteArray@1100012 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Array";
Uri@1100006 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Uri";
HttpWebResponse@1100010 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebResponse";
StatusCode@1100007 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpStatusCode";
WebServiceUrl@1100004 : Text;
StatusDescription@1100017 : Text[250];
ResponseText@1100015 : Text;
lPackingHeader@1000000001 : Record 50010;
BEGIN
HttpWebRequest := WebRequest.Create(Uri.Uri('https://XXXXXXX/landing.html'));
HttpWebRequest.Method := 'POST';
HttpWebRequest.ContentType := 'application/xml';
ByteArray := Encoding.UTF8.GetBytes(XMLDoc.OuterXml);
HttpWebRequest.ContentLength := ByteArray.Length;
RequestStream.Write(ByteArray,0,ByteArray.Length);
TryGetWebResponse(HttpWebRequest,HttpWebResponse);
StatusCode := HttpWebResponse.StatusCode;
StatusDescription := HttpWebResponse.StatusDescription;
ResponseText := ReadHttpResponseAsText(HttpWebResponse);
lPackingHeader.ProcessResponse(ResponseText,PackingNo);
END;
0
Answers
-
No one has any clue? may be a format from DOMDOcument to XMLDocument in .NET... I am quite lost with this, I will probably have to change all the way of generatingthe XML and use an DotNet XML type....0
-
If the problem is the Automation against the DotNet, you could save the XML and load agian, something like this:
Name DataType Subtype Length XMLDocDotNet DotNet System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLDoc.save(FileName); XMLDocDotNet.Load(FileName);
And then use the XMLDocNet var in place of XMLDoc.
Regards0 -
If the problem is the Automation against the DotNet, you could save the XML and load agian, something like this:
Name DataType Subtype Length XMLDocDotNet DotNet System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLDoc.save(FileName); XMLDocDotNet.Load(FileName);
And then use the XMLDocNet var in place of XMLDoc.
Regards
Yes, really thanks! That is what I was specting, but I couldn't find it! What type should "filename" be? A string? What does it represent?
Really appreciate!0 -
File Name is a string and the path and name of a file where you save the XML and then you load the saved XML to the XMLDocDotNet var.0
-
File Name is a string and the path and name of a file where you save the XML and then you load the saved XML to the XMLDocDotNet var.
Again, thank you very much. i was getting mad with this issue, and the worst thng is that I was thinking about it, but dindn't find the way. I will work on this solution
Really appreciated!0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
