如何更改SOAP请求的HTTP头?

时间:2018-02-20 08:48:46

标签: php http soap zend-framework header

我在PHP中发送SOAP请求,但服务器SOAP需要一个apikey。这个apikey 应该放在http请求的标题中。

RewriteRule ^(.+)\.php\.$ $1.php [R=301,QSA,L]

但这是结果:

$context = stream_context_create(array(
'http' => array(
    'method' => 'GET',
    'header' => 'Content-type: text/xml\r\n'.
    'apikey: *************************************\r\n'
    )
));

$options = array(   
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => 1,
'soap_version' => SOAP_1_1,
'exceptions' => true,
'stream_context' => $context
);

$client = new SoapClient("file wsdl", $options); 

如您所见,请求标头不包含apikey。我也尝试使用zendsoap函数。

我的配置: - 窗户8 - wamp 3.1.0 - php 5.6.31

有任何线索可以帮我解决这个问题吗?

谢谢,

1 个答案:

答案 0 :(得分:0)

您需要将apiKey作为请求标头的一部分发送。

你应该尝试这样的事情:

'header' => 'Content-type: text/xml\r\napikey: *******\r\n'.