Save a SOAP message to XML

ta5
Member Posts: 1,164
Hello
Based on this post
viewtopic.php?t=24825
I came to the conclusion, that I will be better for debugging and logging purposes to save all outgoing soap messages to xml.
With *incoming* SOAP-Messages it works like this:
Does anybody know how to save *outgoing* soap messages to xml before they are sent to the webservice?
This is a part of the code how the message is sent:
Many thanks in adance.
Thomas
Based on this post
viewtopic.php?t=24825
I came to the conclusion, that I will be better for debugging and logging purposes to save all outgoing soap messages to xml.
With *incoming* SOAP-Messages it works like this:
CREATE(XMLDom); XMLDom.async := FALSE; XMLDom.load(SoapHttpConn.OutputStream); XMLDom.save('c:\something.xml');
Does anybody know how to save *outgoing* soap messages to xml before they are sent to the webservice?
This is a part of the code how the message is sent:
SoapSerialize.StartElement('param'); .. SoapSerialize.EndElement; SoapSerialize.EndBody; SoapSerialize.EndEnvelope; SoapHttpConn.EndMessage;
Many thanks in adance.
Thomas
0
Answers
-
Hello Thomas,
Here's a simple out of the box working solution..
http://www.mibuso.com/forum/viewtopic.p ... 952#110952Met vriendelijke groet, best regards,
Rvduuren0 -
Hi Rvduuren
Thanks for replying. I can see the part where you save the soap response, but I can't find the part where you save the soap request (the message that is beeing sent to the webservice). Am I blind? :?
Thanks in advance
Thomas0 -
The xml file should like this.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types"> <soapenv:Header/> <soapenv:Body> <urn:checkVat> <countryCode>?</countryCode> <vatNumber>?</vatNumber> </urn:checkVat> </soapenv:Body> </soapenv:Envelope>
I usually do not use SOAP Microsoft Soap Type Library, but xmlHTTP automation, and create the xml using xmlport.
Here is an example
http://mibuso.com/blogs/ara3n/2008/03/0 ... -navision/0 -
BTW I use soapUI program to connect to webservices and see all the request and how the xml file should look like.0
-
ara3n wrote:BTW I use soapUI program to connect to webservices and see all the request and how the xml file should look like.
Thanks for your valuable post on this. With soapUI I was able to see how the XML should look like. Very helpful as everybody who has ever seen a complex wsdl file probably would confirm.
Anyway, is it possible to save the outgoing soap from the navision client? I actually cannot imagine why it doesnt work, particulary because saving the incoming soap is just that simple ](*,)
Regards
Thomas0 -
To see the xml file, you need to direct the soapserialize to a different location
MyFile.CREATE('c:\xml2.xml'); MyFile.CREATEINSTREAM(Istream); Serializer.Init(Istream); //t Serializer.Init(Connector.InputStream); Serializer.startEnvelope('','STANDARD','utf-16'); Serializer.startBody('STANDARD'); Serializer.startElement('checkVat','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.startElement('countryCode','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.writeString('GB'); Serializer.endElement; Serializer.startElement('vatNumber','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.writeString('704767477'); Serializer.endElement; Serializer.endElement; Serializer.endBody; Serializer.endEnvelope; MyFile.CLOSE;
0 -
Hi Rashed
Thanks for the code, very much appreciated! Unfortunately the file is still empty after running that code. We are using Navision 3.7, soap3.0
Does it work on your installation?
Regards and thanks in advance
ThomasCREATE(Serializer); MyFile.CREATE('c:\temp\file2.xml'); MyFile.CREATEINSTREAM(myInstream); Serializer.Init(myInstream); Serializer.StartEnvelope('','STANDARD','utf-16'); Serializer.StartBody('STANDARD'); Serializer.StartElement('checkVat','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.StartElement('countryCode','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.WriteString('GB'); Serializer.EndElement; Serializer.StartElement('vatNumber','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.WriteString('704767477'); Serializer.EndElement; Serializer.EndElement; Serializer.EndBody; Serializer.EndEnvelope; MyFile.CLOSE;
0 -
Yes it works in my example
I use Microsoft Soap Type Library V1 in 5.0 exe.0 -
ara3n wrote:To see the xml file, you need to direct the soapserialize to a different location
MyFile.CREATE('c:\xml2.xml'); MyFile.CREATEINSTREAM(Istream); Serializer.Init(Istream); //t Serializer.Init(Connector.InputStream); Serializer.startEnvelope('','STANDARD','utf-16'); Serializer.startBody('STANDARD'); Serializer.startElement('checkVat','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.startElement('countryCode','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.writeString('GB'); Serializer.endElement; Serializer.startElement('vatNumber','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.writeString('704767477'); Serializer.endElement; Serializer.endElement; Serializer.endBody; Serializer.endEnvelope; MyFile.CLOSE;
Interesting topic :-k
What are these functions?
Serializer.endElement;
Serializer.startElement0 -
It's Microsoft Soap Type Library with serializer class.0
-
Thx, just tried using it...and understanding..Nice
Are there more code examples?0 -
0
-
Yes, I've reread that one too .. and in there removal of namespace!, xlt files!, saving into the blob!, I understand it a little bit more now and will start by creating a webservice for a small webshop.
It was thinking of doing this with a simple import/export but this looks to be the future of things to come. It all looks so complicated with all those definitions.0 -
Yes web services is will be used a lot in the future. Here is another blog on how to use it
http://mibuso.com/blogs/ara3n0 -
I just gave it antother try this morning. It still does not work but what is kind of interesting that Nav 3.7 client crashes if "message" or "sleep" is used in the code.
Thomas0 -
Can't you save your xml file first. Then use SoapUI to send and debug it? It will give you much more info then NAV.0
-
-
Download the 5.0 sp1 from mibuso download section and try your code in it. See if you get the result.0
-
ara3n wrote:Download the 5.0 sp1 from mibuso download section and try your code in it. See if you get the result.
Bingo! \:D/ It works with 5.0 and 5.0 SP1, but not with 3.7! Since the installation in question will upgrade to 5.0 anyway this is ok for us.
Thanks for all your help, espacially to Rashed.
Thomas0 -
You are welcome, and good luck.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