0

所以我有一个提要,它要求我发送一个标题为“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 请求与第一个示例块如此不同?我怎样才能让它看起来一样?

4

0 回答 0