2012-12-06 42 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) 
));