可以更改所使用的HTTP標頭,但只能通過擴展PHP的本機SoapClient類。
事情是這樣的:
class MySoapClient extends \SoapClient
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
//Send the HTTP request and get the response using curl or fsockopen,
//of course setting Content-Encoding to accept-gzip,accept-deflate.
//Also set Accept-Encoding to deflate
//Put the response in a variable called $response
//Set the headers used for this request; this is how you would do it if you used curl:
$this->__last_request_headers = curl_getinfo($curlHandle, CURLINFO_HEADER_OUT);
$this->__last_request = $request;
//decompress the response
$response = gzinflate(substr($response, 10, -8));
return $response;
}
}
看來,OP已經意識到了這一點,但在這裏是爲別人小費誰可能沒有意識到這一點:看SOAP請求,因爲它會被髮送通過了PHP的原生SoapClient類外,設置「追蹤」選項設置爲true:
$client = new \SoapClient($wsdlPath, array('trace'=>true));
然後,在執行您的SOAP請求後,你可以做到這一點,看看中使用的標題:
var_dump($client->__getLastRequestHeaders());
SOAP頭是不一樣的HTTP頭,這種變化需要在實際的HTTP請求,而不是在SOAP請求作出。 – pogo 2010-11-16 09:34:55