0

I'm having a problem in order to create a soap call. As one can see the header that is being supplied from a 3rd party client doesn't have a header name. I need to create a soap call by passing the username and password to the soap request which doesn't have a name in the header. I have tried several examples but no success. The call below works in soap UI but I'm having serious problems when it comes to php. Any help would be much appreciated

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://namespace.example.com/">
   <soapenv:Header>
      <int:password>123</int:password>
      <int:login>abc</int:login>
   </soapenv:Header>
   <soapenv:Body>
      <int:getEventTree>
         <!--Optional:-->
         <lang>en</lang>
      </int:getEventTree>
   </soapenv:Body>
</soapenv:Envelope>
4

1 回答 1

0

请看一下http://php.net/manual/en/soapclient.dorequest.php

您可以使用如下代码:

$response = $soapClient->__doRequest(
    $request,
    $endpoint,
    $soapAction,
    $soapVersion,
    $one_way       
);

$request 可以定义为包含 xml 的字符串,例如:

$request = 
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/""xmlns:int="http://namespace.example.com/">
    <soapenv:Header>
        <int:password>123</int:password>
        <int:login>abc</int:login>
    </soapenv:Header>
    <soapenv:Body>
        <int:getEventTree>
            <!--Optional:-->
            <lang>en</lang>
        </int:getEventTree>
    </soapenv:Body>
</soapenv:Envelope>';

您可以根据您的配置在 __doRequest() 调用中定义其余参数。

于 2013-03-12T19:01:16.627 回答