在我的 wsdl 文件中,我有一个用户身份验证块:
<!-- User authentication -->
<element name="UserAuthentication">
<complexType>
<sequence>
<element name="iId" type="xsd:int" />
<element name="sPassword" type="xsd:string" />
<element name="sType" type="api:UserType" />
</sequence>
</complexType>
</element>
我正在尝试实例化一个 SOAP 调用,如下所示:
$client = new SoapClient("http://api.example.com/v2/example?wsdl",
array(
'iId' => 123456,
'sPassword' => 'fhfhfhfhfhfhfh46464dtdts64iyiyi',
'sType' => 'ghfh57477gghdkskdk68585jghhddhdghds'));
并提供实际值。脚本报告:
SoapFault exception: [ns1:Client.AUTH_1] Authentication Failed in
我缺少什么?
您正在将请求数据传递到内部options for SoapClient
而不是作为肥皂调用的参数。
代码应该如下所示(假设肥皂调用是Authenticate
):
$client = new SoapClient("http://api.example.com/v2/example?wsdl");
$response = $client->Authenticate(Array(
'iId' => 123456,
'sPassword' => 'fhfhfhfhfhfhfh46464dtdts64iyiyi',
'sType' => 'ghfh57477gghdkskdk68585jghhddhdghds'));
));
并且,无论如何,您应该使用try..catch
以防止异常导致代码崩溃。
try
{
// code here
}
catch(Exception $e)
{
// error handling goes here
die("Error: ". $e->getMessage()."\n");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)