我对使用SOAP非常陌生,我希望创建一些客户端软件,连接到一个没有为PHP提供资源/演示的现有服务。我想确定我的代码是做错了什么,还是可能是系统问题(我已经在Windows 2008 R2环境中创建了Apache2.4/PHP7.2.7 )。
我已经花了几个小时测试一些东西,并在这里浏览了许多其他SOAP/PHP主题,而我自己创建线程的区别在于,身份验证是SoapClient调用中所必需的,而不是$client->_soapCall(function,params)调用。
首先,这是我在PHP中拥有的内容。
$customerArray = array( $cust1 , $cust2, $cust3 );
$credentials = array(
'login' => $login,
'password' => $password,
);
try{
$client = new SoapClient($soaplink);//, $credentials);
} catch (Exception $e) {
echo "<h2>Exception Error in SoapClient</h2>";
echo $e->getMessage();
}
var_dump($client->__getFunctions());
try{
$response = $client->__soapCall("getCustomers", array($customerArray, $credentials));
}catch (Exception $e) {
echo "<h2>Exception Error in soapCall</h2>";
echo $e->getMessage();
}
var_dump($response());使用或不带凭据数组,第一个try块将完成。第二个try块在尝试调用函数时返回异常“看起来我们没有XML文档”。
SOAP服务提供了演示XML文件,此函数的示例XML文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getCustomers
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://ws.praxedo.com/2008_07_01/customermodel/service"
>
<in0
soapenc:arrayType="soapenc:string[3]"
xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>
<in0 xsi:type="soapenc:string">CUSTOMER001</in0>
<in0 xsi:type="soapenc:string">CUSTOMER002</in0>
<in0 xsi:type="soapenc:string">CUSTOMER003</in0>
</in0>
<in1
xsi:type="soapenc:string"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>
login|password
</in1>
</ns1:getCustomers>
</soapenv:Body>
</soapenv:Envelope>还提供了WSDL文件,我可能需要从它加载,但在演示之后,如果没有结果,就可以这样做。我可以在这里包含一些WSDL,但是我相信XML提供了所有相关的细节?
所以,有人能看到我在PHP中做错了什么吗,或者我应该做什么工作,我需要查看客户端Apache/SOAP服务器端吗?
发布于 2018-07-06 12:13:47
我强烈建议您在PHP生成器中使用WSDL,因为它将允许您构造请求,而不会有任何疑问(至少取决于您的PHP知识水平)。
尝试PackageGenerator项目。您必须安装它,然后生成PHP。生成的SDK使用composer,并包含发送任何请求所需的所有类和方法。看看自动生成的tutorial.php文件,这是一个很好的起点。
https://stackoverflow.com/questions/51181406
复制相似问题