簡體   English   中英

如何設置這樣的肥皂頭(PHP)

[英]How to set such soap header (php)

我已收到此示例進行肥皂查詢:

POST https://000.0.0.0:8181/wsForWeb/webService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Authorization: Basic username:password
Content-Length: 293
Host: 000.00.00.00:8181
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws/">
<soapenv:Header/>
 <soapenv:Body>
  ....
 </soapenv:Body>
</soapenv:Envelope>

如何用肥皂發送這些標頭? 通常我會用

$client = new soapClient(...);
$clHeader = new SoapHeader(..., array('
            'authorization' => 'Basic .......',
            'Host' => '000.000.00.00.0',
            ));
$client -> __setSoapHeaders($clHeader);

但是我收到驗證錯誤。 我究竟做錯了什么?

您沒有在soap Header中傳遞登錄憑據

$params = array(
   "login" => "username", 
   "password" => "password", 
);

$client = new SoapClient($wsdlURL, $params);

其中$ wsdlURL是帶有Soap調用所在服務器的URL的變量。

這是使用基本身份驗證實現Soap Client的最常見方法

參考PHP官方文檔: 鏈接。

希望這會有所幫助

暫無
暫無

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

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