在PHP 28年3月5日和SoapClient想創建SOAP頭,看起來像:PHP SoapClient的 - 如何構建SOAP頭
<soap:Header>
<ns:RequestParams Size="Large" Color="Blue" Brand="xyz">
</soap:Header>
如果你建造這樣的標題:
$params = array('RequestParams' => array('Size' => 'Large', 'Color' => 'Blue', 'Brand' => 'xyz');
$header = new SoapHeader(NameSpace, 'RequestParams', $params);
$client = new SoapClient(NULL, array("location" => "https://endpoint-url",
"uri" => "http://namespace-uri",
"soap_version" => SOAP_1_2, "trace" => 1));
$client->__setSoapHeaders($header);
$result = $client->__soapCall(some soap call here);
echo $client->__getLastRequest() . "\n";
我得到的標題是:
<env:Header>
<ns2:RequestParams>
<item><key>RequestParams</key><value>
<item><key>Size</key><value>Large</value></item>
<item><key>Color</key><value>Blue</value></item>
<item><key>LastName</key><value>xyz</value></item></value>
</item>
</ns2:RequestParams>
</env:Header>
,我得到來自服務器的響應告訴我這是一個無效的頭。我已經搜索過,並且似乎沒有太多關於PHP soapclient如何從數據結構創建標題的信息。任何想法如何使用SoapClient獲得標題格式? 任何指針讚賞。
想我還是去與此解決方案:http://stackoverflow.com/questions/690262/how-can-i-create-a-soap-頭樣本 – user3455353