使用php将用户名写入http头以进行Web服务身份验证

时间:2014-01-25 06:08:46

标签: php soap http-headers

我的代码:

$url = "http://x.x.x.x/ws/special/Service?wsdl";  
$context = stream_context_create(array('http' => array( 'username' => "jonas" )));  
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));  
$res = $client->__soapCall("getinfo",array('counter'=>'10'));  

错误: -

Fatal error: Uncaught SoapFault exception: [S:Server] missing parameter 
'username' in C:\xampp\htdocs\test.php:7 Stack trace: #0 
C:\xampp\htdocs\test.php(7): SoapClient->__soapCall('getAsinfo...', Array)
#1 {main} thrown in C:\xampp\htdocs\test.php on line 7

如何写入http标头?

0 个答案:

没有答案