ShowMessage(MyMessage : Text[30]) outputtext : Text[30] EXIT(MyMessage);
OnRun() CREATE(XMLDoc); CREATE(XMLDoc2); XMLDoc.async := FALSE; XMLDoc.load('C:\Input.xml'); CREATE(XMLHTTP); XMLHTTP.open('POST','http://localhost:7047/DynamicsNAV/WS/CRONUS_New_Zealand_Ltd/Codeunit/MyWebService',0); XMLHTTP.setRequestHeader('Content-type','text/xml'); XMLHTTP.setRequestHeader('SOAPAction', 'http://localhost:7047/DynamicsNAV/WS/CRONUS_New_Zealand_Ltd/Codeunit/MyWebService:ShowMessage'); XMLHTTP.send(XMLDoc); XMLDoc2.load(XMLHTTP.responseXML); XMLDoc2.save('C:\Output.xml'); FoundXMLNode := XMLDoc2.selectSingleNode('Soap:Envelope/Soap:Body/MyWebService_Result/return_value'); IF XMLHTTP.status = 200 THEN BEGIN IF ISCLEAR(FoundXMLNode) THEN MESSAGE('NOT FOUND') ELSE MESSAGE('%1',FoundXMLNode.text) END ELSE MESSAGE('%1',XMLHTTP.responseText);
<?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 > <ShowMessage xmlns="http://localhost:7047/DynamicsNAV/WS/CRONUS_New_Zealand_Ltd/Codeunit/MyWebService"> <MyMessage>This is a Test</MyMessage> </ShowMessage> </soap:Body> </soap:Envelope>
Answers
thanks.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
The NAV function I have published as a webservice is the ShowMessage in the My Web Service codeunit.
My Web Service:
The full codeunit looks like this:
OBJECT Codeunit 51102 My Web Service
{
OBJECT-PROPERTIES
{
Date=07/05/09;
Time=13:42:11;
Modified=Yes;
Version List=;
}
PROPERTIES
{
OnRun=BEGIN
END;
}
CODE
{
PROCEDURE ShowMessage@1000000001(MyMessage@1000000000 : Text[30]) outputtext : Text[30];
BEGIN
EXIT(MyMessage);
END;
BEGIN
END.
}
}
I can run the webservice if I remove the parameter MyMessage in the ShowMessage functions and replaces the variable with a plain text.
Regards
Claus
http://www.AcumenConsulting.co.nz
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I tried to change the input.xml file to your suggestion but I am still getting the same error.
Do you have any other suggestions?
Regards
Claus
Microsoft Dynamics NAV Classic
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Service.WebServices.ServiceBrokerException</faultcode><faultstring xml:lang="en-NZ">Parameter myMessage in method ShowMessage in service MyWebService is null! </faultstring><detail><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Parameter myMessage in method ShowMessage in service MyWebService is null! </string></detail></s:Fault></s:Body></s:Envelope>
OK
http://www.AcumenConsulting.co.nz
I have tried to replicate the code in Visual Studio but I still get the same error.
Error:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Service.WebServices.ServiceBrokerException</faultcode><faultstring xml:lang="en-NZ">Parameter myMessage in method ShowMessage in service MyWebService is null! </faultstring><detail><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Parameter myMessage in method ShowMessage in service MyWebService is null! </string></detail></s:Fault></s:Body></s:Envelope>
OK
I have also tried to test tHe web service in visual studio using a Web References and the web service works when I do this.
So the issue is definitly how to get the parameter passed when using SOAP. Do you know if there is another way I can call the web services from NAV?
Thanks
Claus
http://www.AcumenConsulting.co.nz
http://blogs.msdn.com/freddyk/archive/2008/11/24/search-in-nav-2009-part-3-out-of-3.aspx
I do the same from Javascript. The code is:
This runs on my machine.
The AL function looks like:
DoSearch(searchstring : Text[40];VAR result : BigText)
Good luck
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.
I tried your suggestion but I still get the same error. I then tried to change parameters, making the parameters var parameters and removing the return value in NAV and suddenly it worked. I had no clue why so I played a bit more and noticed all my variables were in lower case. I also noticed that the original error message referred to myMessage (first letter in lower case) despite the variable being declared as MyMessage in NAV and in the Input.xml file.
I changed my original function in NAV to
The parameter MyMessage is changed to mymessage (all letters in lower case)
and the input.xml I changed MyMessage to mymessage (all letters in lower case again)
The web service works when I use yours suggestion for the input.xml but not when I am using my original file or arn3n suggestion.
Anyway, I guess you have to be careful when you use mix lower and upper case letter. Maybe this will be fixed in SP1.
Thanks again arn3n and Freddy for your help.
Regards
Claus
http://www.AcumenConsulting.co.nz