所以我有一个Feed,它要求我发送带有用户名和密码的标题标题“CredentialsHeader”,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<CredentialsHeader xmlns="http://www.property24.com/Services/P24ListingService13">
<EMail>string</EMail>
<Password>string</Password>
</CredentialsHeader>
</soap12:Header>
....
所以要在我的PHP中做到这一点:
$headers = array();
$CredentialObject = new SoapVar(array('EMail' => 'ricky@email.com', 'Password' => 'test'), SOAP_ENC_OBJECT);
$headers[] = new SoapHeader('dto', "CredentialsHeader", $CredentialObject, false
);
$client->__setSoapHeaders($headers);
$client->__soapCall('EchoAuthenticated', array("hello"=>"hi"));
现在我的请求看起来像是
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.property24.com/Services/P24ListingService13" xmlns:ns2="dto">
<SOAP-ENV:Header>
<ns2:CredentialsHeader>
<EMail>ricky@email.com</EMail>
<Password>test</Password>
</ns2:CredentialsHeader>
</SOAP-ENV:Header>
....
这使验证失败 - 为什么我生成的SOAP请求与第一个示例块有如此不同?我怎样才能让它看起来一样?