user1390456
user1390456

Reputation: 96

Access to Navision codeunit via web service (xml)

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>

Upvotes: 0

Views: 6290

Answers (2)

user1390456
user1390456

Reputation: 96

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"

Upvotes: 1

Mak Sim
Mak Sim

Reputation: 2314

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.

Upvotes: 0

Related Questions