Question

I try to access the Navision 2009 R2 web service by generating a SOAP message from C#. I get the response only if the codeunit's function I call has no parameters.

Example for codeunit RunJob function Test (no parameters, returns a hardcoded string):

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Test xmlns="urn:microsoft-dynamics-schemas/codeunit/runjob">
</Test>
</soap:Body>
</soap:Envelope>

As result I get that string...

Example for same codeunit RunJob function RunJob (takes 1 string parameter named parameter, returns an internal server error):

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<RunJob xmlns="urn:microsoft-dynamics-schemas/codeunit/runjob">
<parameter>aaaa</parameter>
</RunJob>
</soap:Body>
</soap:Envelope>

As result I get the error (WebResponse wr = request.GetResponse();) instead of the needed info.

The most interesting thing is that it worked before. The only changes (as for me) - NAV 2013 was installed.

Has anyone experienced the same issue or knows the solution?

P.S. Here is a part of the web service definition for the RunJob function:

<element name="Runjob">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="parameter" type="string"/>
</sequence>
</complexType>
</element>
<element name="Runjob_Result">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="return_value" type="string"/>
</sequence>
</complexType>
</element>
Was it helpful?

Solution

It was all about the function/variables naming. The first letter of the each parameter of the function should be small one. The SOAP body should be like this ("codeunit" is in lowercase, but it's name is as exposed in NAV)

<RunJob xmlns="urn:microsoft-dynamics-schemas/codeunit/RunJob">
...params...
</RunJob>

the Request header (codeunit name in lower case, function name as it is)

"urn:microsoft-dynamics-schemas/codeunit/runjob:RunJob"

OTHER TIPS

It sound awkward but try to put

<soap:Body><RunJob xmlns="urn:microsoft-dynamics-schemas/codeunit/runjob">

in single line, i.e. no carriage return between Body and RunJob.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top