2010-11-30 91 views
5

我是很新的SOAP(即沒有任何線索!)問題在PHP發送SOAP AUTH頭

有人問我有一個客戶與需要通過我的SOAP頭進行身份驗證現有的SOAP服務交互(一簡單的用戶名和密碼)

我已經在我手上3種方法,

的IsAlive IsAliveSecure ChangeUserDetails

簡單的IsAlive返回true,我可以把它叫做無問題

IsAliveSecure通過適當的授權返回true,我無法讓它返回true。

基本上我需要發送以下請求:

POST /ripplecomprovisioning.asmx HTTP/1.1 
Host: provisioning.example.ie 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://www.blueface.ie/provisioning/IsAliveSecure" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
    <SoapAuthHeader xmlns="http://www.example.ie/provisioning/"> 
     <Username>myusername</Username> 
     <Password>mypassword</Password> 
    </SoapAuthHeader> 
    </soap:Header> 
    <soap:Body> 
    <IsAliveSecure xmlns="http://www.example.ie/provisioning/" /> 
    </soap:Body> 
</soap:Envelope> 

我的問題是如何發送格式類似於在PHP上面的要求?

這是我試過,但沒有成功:

$ SoapClient的=新SoapClient的( 「https://provisioning.example.ie/ripplecomprovisioning.asmx?WSDL」);

// Prepare SoapHeader parameters 
$sh_param = array( 
      'Username' => 'myusername', 
      'Password' => 'mypassword'); 
$headers = new SoapHeader('ripplecomprovisioning', 'SoapAuthHeaders', $sh_param); 

// Prepare Soap Client 
$soapClient->__setSoapHeaders(array($headers)); 
    $result = $soapClient->isAlive(); 

echo var_dump($result); 

echo "<br /><br />"; 

    $result = $soapClient->IsAliveSecure(); 

echo var_dump($result); 

從上述輸出如下:

object(stdClass)#3 (1) { 
    ["IsAliveResult"]=> 
    bool(true) 
} 
<br /><br /> 
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.UnauthorizedAccessException: Attempted to perform an unauthorized operation. 
    at example.VoIP.Provisioning.RipplecomProvisioningServices.IsAliveSecure() 
    --- End of inner exception stack trace --- in /var/www/ripplecomweb/authentication/soap.php:20 
Stack trace: 
#0 [internal function]: SoapClient->__call('IsAliveSecure', Array) 
#1 /var/www/ripplecomweb/authentication/soap.php(20): SoapClient->IsAliveSecure() 
#2 {main} 
    thrown in /var/www/ripplecomweb/authentication/soap.php on line 20 

任何幫助,這將不勝感激。我承受不起失敗!

感謝

千電子伏

回答

1

那麼這將是一個容易得多,如果我們可以看到該服務的WSDL。 但請嘗試執行以下步驟:

1.檢查isDLiveSecure方法的WSDL以查看是否必須傳遞某些內容。

2.See你要發送的請求,真的是這樣的:

var_dump($soapClient->__getLastRequest()); 
var_dump($soapClient->__getLastRequestHeaders()); 

(確保你實例化$soapClient用這些方法的選項'trace' => TRUE,否則將無法正常工作 - >見PHP manual )。

3.Try發送在你一定應該是正確的通過命令行手動形式的要求,是這樣的:

curl -v -k -d @/path/to/the/file/with/the/request/xml http://service_url