2012-12-06 46 views
1

我的SOAP请求WSDL显示如下一样,通行证头认证信息以WSDL

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
<SOAP-ENV:Body><unit>3452</unit> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

但我有发送HTTP认证参数对SOAP头和SOAP服务器抓获。

$client = new SoapClient("call.wsdl",array(
"trace"  => 1, 
"exceptions" => 0, 
"login" => 'xxxxx', 
"password" => 'xxxx')); 

$result = $client->getCALL($unit); 

我的SOAP身份验证参数发送到服务器,但它不显示在SOAP请求文本上。我需要在请求消息中看到它们。

我需要在WSDL文件上添加哪些类型的代码以获取请求文本,如下所示。

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Header> 
    <Login>BonZ</Login> 
    <Password>xxxx</Password> 
    </SOAP-ENV:Header> 
    <SOAP-ENV:Body> 
    <unit>3452</unit> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

回答

2
$CREDENTIALS = 'Login:Password'; 
     $auth = base64_encode($CREDENTIALS); 
     $context = array('http' => 
      array(
       'header' => "Authorization: Basic ".$auth 
      ) 
     ); 

$trac["stream_context"]=stream_context_create($context); 
$client = new SoapClient("call.wsdl",array(
"trace"  => 1, 
"exceptions" => 0, 
"login" => 'xxxxx', 
"password" => 'xxxx' 
"stream_context"=>stream_context_create($context) 
));