SOAP request

Torben_R.
Member Posts: 99
I'm struggling with a SOAP request in NAV 5.0. I have to connect to a webshop where they use OpenBizBox.
The correct header for the request must look like this:
When I create it in NAV 5.0 the request is empty.
If I try this:
I get a request that can be send but I get an error back - Version Mismatch
The difference is in the line xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" where only SOAP-ENC is accepted by the webshop and SOAP-ENV by NAV ](*,) ](*,) ](*,)
I have tried to leave out the line and a number of other things, but nothing seems to work.
Any good ideas?
The correct header for the request must look like this:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://some.shopdomain.com/soap.php" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> etc.....
When I create it in NAV 5.0 the request is empty.
If I try this:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://some.shopdomain.com/soap.php" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> etc.....
I get a request that can be send but I get an error back - Version Mismatch
The difference is in the line xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" where only SOAP-ENC is accepted by the webshop and SOAP-ENV by NAV ](*,) ](*,) ](*,)
I have tried to leave out the line and a number of other things, but nothing seems to work.
Any good ideas?
0
Answers
-
Hi Torben
How do you create the Soap Request? Do you use MS XML 6.x?
Regards
Thomas0 -
Yes.
-
Name DataType Subtype
XMLHttp Automation 'Microsoft XML, v6.0'.XMLHTTP60
XMLDomDoc Automation 'Microsoft XML, v6.0'.DOMDocument
XMLDomNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
CGBase64 Automation 'CG Request Client'.Base64
ADOStream Automation 'Microsoft ActiveX Data Objects 2.7 Library'.Stream
XMLBody[1] := '<?xml version="1.0" encoding="utf-8"?>'+ '<SOAP-ENV:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" ' + 'xmlns:ns1="' + Setup."Web Address" + '" ' + 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' + 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' + '<SOAP-ENV:Body>'+ '<ns1:OpenBizBox_XML>'+ '<param0 xsi:type="xsd:string">'; ADOStream.LoadFromFile(TEMPORARYPATH + TempFile); XMLBody[2] := ADOStream.ReadText(1024); XMLBody[2] := DELSTR(XMLBody[2],1,STRLEN(ImportedString)); XMLBody[3] := '</param0>' + '</ns1:OpenBizBox_XML>' + '</SOAP-ENV:Body>'+ '</SOAP-ENV:Envelope>'; ADOStream.Close; XMLDomDoc.loadXML(XMLBody[1] + XMLBody[2] + XMLBody[3]); XMLDomDoc.async:=FALSE; IF Setup."Save Request" THEN XMLDomDoc.save(Setup."Request File Name"); // For Test XMLHttp.open('POST',Setup."Web Address"); XMLHttp.setRequestHeader('Content-Type','text/xml; charset=utf-8'); XMLHttp.setRequestHeader('SOAPAction',Setup."Web Address" + '#OpenBizBox_XML'); XMLHttp.send(XMLDomDoc.xml); XMLDomDoc.load(XMLHttp.responseXML);
I have access to a testsite where I can enter and test the content of the envelope, see the complete request and see the result. The content is ok - the only problem (for now) is the SOAP-ENC/SOAP-ENV line in the request.0 -
I have tested the same in NAV 2009 R2 with the same result.0
-
Hi
Imo it's better not to add xml content combining parts with '+' like a text. Better use xmlDOMDoc to add the content. This way you have full control of the Document and if there is a problem normally you'll find out very soon.
Try this:
http://www.mibuso.com/dlinfo.asp?FileID=1384
Anyway, what happens if you replace the 2. ENV by ENV? If you use a tool like xmlSpy, everything looks ok, no schema errors, etc.?0 -
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://some.shopdomain.com/soap.php" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
your SOAP-ENV was not created in the correct order. Use above.
When I have problems with an xml, I save it and open it up in www.firstobject XML editor. Hope it helps.0 -
mdPartnerNL wrote:your SOAP-ENV was not created in the correct order. Use above.
Thats what I mean. I you use xmlDomDoc to create, it's not possible to add "uneven" tags/elements, the document has to be well formed.0 -
Hi guys. The structure is ok!!!!!!
If I use ENV I can open the request in Internet Explorer.
NAV will not create the request if I use ENC - and it has to be ENC0 -
Torben R. wrote:Hi guys. The structure is ok!!!!!!
If I use ENV I can open the request in Internet Explorer.
NAV will not create the request if I use ENC - and it has to be ENC
Have you used e.g. SOAPUI or Fiddler to catch the communication and the real message send to the server when using -ENC? It seems that you haven't changed the ENV for ENC everywhere where needed.0 -
According to the description ENC is only used in one line and ENV in all the others. I have tried to use ENC in other lines as well without success.
I save the request as a file before it's send.
With ENC I get an empty file and with ENV a correct structured file.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