POST /WSNAV/Service.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/UpString" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <UpString xmlns="http://tempuri.org"> <toUP>string</toUP> </UpString> </soap:Body> </soap:Envelope>Navision code
baseURL := 'http://localhost/WSNAV/Service.asmx/'; result := FALSE; URL := baseURL+'UpString'; method := 'UpString'; namespace := 'http://tempuri.org'; parameters := '<toUP>prova</toUP>'; // Create XML Document CREATE(xmldoc,TRUE,TRUE); // Create SOAP Envelope soapEnvelope := xmldoc.createElement('Soap:Envelope'); soapEnvelope.setAttribute('xmlns:Soap', 'http://schemas.xmlsoap.org/soap/envelope/'); xmldoc.appendChild(soapEnvelope); // Create SOAP Body soapBody := xmldoc.createElement('Soap:Body'); soapEnvelope.appendChild(soapBody); // Create Method Element soapMethod := xmldoc.createElement(method); soapMethod.setAttribute('xmlns', namespace); soapBody.appendChild(soapMethod); // Transfer parameters by loading them into a XML Document and move them CREATE(parametersXmlDoc,TRUE,TRUE); parametersXmlDoc.loadXML('<parameters>'+parameters+'</parameters>'); IF parametersXmlDoc.firstChild.hasChildNodes THEN BEGIN WHILE parametersXmlDoc.firstChild.childNodes.length>0 DO BEGIN node := parametersXmlDoc.firstChild.firstChild; node := parametersXmlDoc.firstChild.removeChild(node); soapMethod.appendChild(node); END; END; // Create XMLHTTP and SEND CREATE(xmlhttp, TRUE, TRUE); xmlhttp.open('POST', URL, FALSE); xmlhttp.setRequestHeader('Content-type', 'text/xml; charset=utf-8'); xmlhttp.setRequestHeader('SOAPAction', method); xmlhttp.send(xmldoc); // If status is OK - Get Result XML IF xmlhttp.status=200 THEN BEGIN xmldoc := xmlhttp.responseXML; xmldoc.setProperty('SelectionLanguage','XPath'); xmldoc.setProperty('SelectionNamespaces','xmlns:tns="'+namespace+'"'); //How I can read the result?? result := TRUE; END ELSE BEGIN MESSAGE(FORMAT(xmlhttp.status)); MESSAGE(FORMAT(xmlhttp.statusText)); MESSAGE(FORMAT(xmlhttp.responseText)); END;
Answers
LnZ
I have a sample on my blog on how to call NAV Web Services from NAV - maybe that can help
http://blogs.msdn.com/freddyk/archive/2010/01/22/connecting-to-nav-web-services-from-microsoft-dynamics-nav-2009-sp1.aspx
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
But I' dont know how to pass this parameter as string, sorry but I'm a newbie ath this type of things
Thank You
LnZ
I have changed my code to pass parameters as string but I still get the same error,If I copy and paste my generated xml into SoapUI it works fine.
It seems a client problem of my navision function.
The exact error I get is this Error 500: System.InvalidOperationException: Request format is invalid
This is my xml for the call:
And this is my new code:
Any Idea?
LnZ