0

我尝试像这样设置 SOAP 标头:

<tns:Authentication xmlns:tns="iSklep3">
    <ApiKey xsi:type="xsd:string">abc</ApiKey>
</tns:Authentication>

我是这样做的:

//...
    $client = new SoapClient($wsdlServer);
    $headerBody = array("ApiKey" => "abc");
    $header = new SoapHeader("iSklep3", "Authentication", $headerBody);
    $client->__setSoapHeaders($header);
//...
//calling soap methods
...

当我调用方法时,它返回的 Api key 是错误的,但它应该是正确的。有人知道 SOAP 标头的问题可能出在哪里吗?

4

1 回答 1

1

设置标题后,您还没有调用 call 函数。

<?php

$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
                                     'uri'      => "http://test-uri/"));
$header = new SoapHeader('http://soapinterop.org/echoheader/', 
                            'echoMeStringRequest',
                            'hello world');

$client->__setSoapHeaders($header);

$client->__soapCall("echoVoid", null);
?>

来源:RTM http://php.net/manual/en/soapclient.setsoapheaders.php

于 2013-03-21T19:19:25.903 回答