【发布时间】:2017-11-03 14:41:25
【问题描述】:
我尝试向 Navision 网络服务发送命令。为了尽可能地了解整个连接,我想首先使用简单的 cURL 命令。
我在 URL https://IP:PORT/.../Codeunit/Webservices 上尝试了简单的 GET 请求。在那里,我得到了一个包含所有命令的很长的 XML 结构。列表的一部分是一个简单的 echo 命令,我可以在其中发送一个字符串并将其取回。
这是它的描述:
<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>
...
现在我的问题是我不知道如何发送命令。我查看了这两个特殊的 SOAP 库:
- https://github.com/jamesiarmes/php-ntlm
- https://github.com/rileydutton/Exchange-Web-Services-for-PHP
我尝试了他们的方法,但没有任何效果。我的代码 sn-p 现在看起来像这样:
$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;
我尝试发送$action 的各种值,但总是收到此错误:
<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>
也许我误解了 navision 的整个 SOAP 流程,但我也没有在网络上找到任何真正好的教程。我究竟做错了什么?感谢您的帮助!
【问题讨论】: