I try to send commands to a Navision web service. To understand the whole connection as best as I can, I want to use at first simple cURL commands.
I experiemented with simple GET Requests on the URL https://IP:PORT/.../Codeunit/Webservices
. There I got a very long XML structure with all the commands. Part of the list is a simple echo command where I can send a string and get it back.
This is the discription of it:
<schema elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-schemas/codeunit/Webservices" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="SoundCheck">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="p_Text" type="string"/>
</sequence>
</complexType>
</element>
<element name="SoundCheck_Result">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="return_value" type="string"/>
</sequence>
</complexType>
</element>
...
Now my problem is that I don't know how to send the command. I looked in these two special SOAP libraries:
- https://github.com/jamesiarmes/php-ntlm
- https://github.com/rileydutton/Exchange-Web-Services-for-PHP
I tried their approches but nothing works. My code snippet now looks like this:
$headers = [
'Method: GET',
'Connection: Keep-Alive',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: "' . $action . '"',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec($ch);
return $response;
I tried to send various values of $action
but I always get this error:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault>
<faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:System.ArgumentNullParametername: input</faultstring>
<detail><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Der Wert darf nicht NULL sein.\nParametername: input</string></detail>
</s:Fault></s:Body></s:Envelope>
Maybe I misunderstood the whole SOAP process with navision, but I also don't found any really good tutorials in the web. What am I doing wrong? Thanks for help!