我繼承了一些php SOAP代碼,並且由於我們正在使用的服務發生更改,我需要修改以「在所有請求的HTTP標頭中添加授權」。我不確定該做什麼,甚至可能。相關代碼的修改PHP/SOAP代碼以在所有請求中添加HTTP標頭
部分看起來是這樣的:
function soap_connect() {
$soap_options = array(
'soap_version' => SOAP_1_2,
'encoding' => 'UTF-8',
'exceptions' => FALSE
);
try {
$this->soap_client = new SoapClient($this->configuration['wsdl'], $soap_options);
} catch (SoapFault $fault) {
return FALSE;
}
return TRUE;
}
我想,我的理解是,它應該只是輸出以下(現在):
Content-Type: application/soap+xml;charset=UTF-8;action="http://ws.testserver.net/nsp/client/hsserve/listHardware"
Content-Length: 255
...
的documentatino說最終的HTTP請求應該如下所示:
Content-Type: application/soap+xml;charset=UTF-8;action="http://ws.testserver.net/nsp/client/hsserve/listHardware"
Authorization: WRAP access_token=Z-H7SnqL49eQ2Qp5pLH8k-RVxHfewgIIDt4VCeI2CNnrS4-gBMzPWbfZuMhgvISVV-uTSikS1SqO0n2PRkH3ysQ-uWbvU9podPAm6HiiIS5W2mtpXUfN9ErBmkjF6hDw
Content-Length: 255
完美。我甚至不知道你可以做到這一點。謝謝! – 2011-01-24 22:24:29