簡體   English   中英

如何在PHP中設置此SOAP標頭

[英]How to set this SOAP header in PHP

我嘗試像這樣設置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鍵是錯誤的,但是應該是正確的。 知道有人SOAP標頭的問題在哪里嗎?

設置標題后,您尚未調用調用函數。

<?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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM