2012-11-23 41 views
0

我需要手動測試一些XML請求,即我想用先前創建的XML請求調用webservice方法。 我正在嘗試使用SoapClient __doRequest,並且所有返回的都是空白的空響應。PHP SoapClient - > __ doRequest

我已經閱讀文檔,以及其他幾個職位在這裏,似乎之前沒有人嘗試這樣做,誰問類似的問題很少,得到了真正沒有任何反應。

再次,做這種方式的原因,它只是一個測試通過在特定的web服務造成問題的其他工具生成的XMLRequest方式。 因此,我不能調用soapclient生成的方法,也不能調用「_call」。 我需要使用SOAPClient發送我自己以前創建的XML請求。 這可能嗎?如果是這樣的話......

$result = $soapClient->__doRequest($docRequest, "http://someservice.asmx", "http://someservice/Login", soap_1_2, 0); 

當我調用這個函數時,我在$ result處得到null而沒有任何錯誤。

+0

我想你的「位置」參數有問題。 – som

+0

「由其他工具生成的XMLRequest」 - 這是「$ docRequest」中的一個嗎? –

+1

要獲得肥皂響應,您必須使用$ client - > __ getLastResponse(); (和或$ client - > __ getLastResponseHeaders();) – noslone

回答

1

http://php.net/manual/soapclient.dorequest.php

也許您的通話將引發你需要捕捉異常:

$exception = null; 
$result = parent::__doRequest($request, $location, $action, $version, $one_way); 
if((isset($this->__soap_fault)) && ($this->__soap_fault != null)) { 
     //this is where the exception from __doRequest is stored 
     $exception = $this->__soap_fault; 
} 

if($exception != null) { 
     throw $exception; 
} 
3

我設法做到這一點是這樣的:

class LocalSoapClient extends SoapClient 
{ 
    function __doRequest($request, $location, $action, $version, $one_way = 0) 
    { 
     $request = "...."; // your changed XML goes here 

     return parent::__doRequest($request, $location, $action, $version, $one_way); 
    } 
} 

$client = new LocalSoapClient($wsdl_url, array('trace' => 1)); 
$client->__soapCall($function_name, array($service_call_params)); 

請注意,你不叫直接__doRequest - 在執行標準__soapCall時執行。