2014-02-22 48 views
0

你好WSO2 ESB社區,如何調用外部PHP Web服務WSO2與ESB

我在PHP中的服務。我已經通過WSDL代理調用WSO2ESB,並沒有問題。但是,當我嘗試從SOAP客戶端或WSO2ESB中內置的「嘗試此服務」調用該服務時,該服務無法調用並顯示錯誤:

org.apache.axis2.AxisFault:讀取超時

你能幫我解決什麼問題..?作爲一個說明,這是PHP服務是順利的話,當電話直接從SOAP客戶端,而不是通過WSO2ESB ..

這是我的PHP服務代碼..

**

<?php 
//call library 
require_once ('../nusoap/lib/nusoap.php'); 
// Create the server instance 
$server = new soap_server(); 
// Initialize WSDL support 
$server->configureWSDL('hellowsdl', 'urn:hellowsdl'); 
// Register the method to expose 
$server->register('hello',    // method name 
    array('name' => 'xsd:string'),  // input parameters 
    array('return' => 'xsd:string'), // output parameters 
    'urn:hellowsdl',     // namespace 
    'urn:hellowsdl#hello',    // soapaction 
    'rpc',        // style 
    'encoded',       // use 
    'Says hello to the caller'   // documentation 
); 
// Define the method as a PHP function 
function hello($name) { 
     return 'Hellooo, ' . $name; 
} 
// Use the request to (try to) invoke the service 
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; 
$server->service($HTTP_RAW_POST_DATA); 
?> 

**

和客戶端看起來像這樣的..

<?php 
require_once ('../nusoap/lib/nusoap.php'); 

// Create the client instance 

$wsdl="http://localhost:8280/services/HelloNuSOAP?wsdl"; 
$client =new nusoap_client($wsdl,true); 
// Check for an error 
$err = $client->getError(); 
if ($err) { 
    // Display the error 
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; 
    // At this point, you know the call that follows will fail 
} 
// Call the SOAP method 
$result = $client->call('hello', array('name' => 'Scott')); 
// Check for a fault 
if ($client->fault) { 
    echo '<h2>Fault</h2><pre>'; 
    print_r($result); 
    echo '</pre>'; 
} else { 
    // Check for errors 
    $err = $client->getError(); 
    if ($err) { 
     // Display the error 
     echo '<h2>Error</h2><pre>' . $err . '</pre>'; 
    } else { 
     // Display the result 
     echo '<h2>Result</h2><pre>'; 
     print_r($result); 
    echo '</pre>'; 
    } 
} 

?> 

客戶端鱈魚的部分e,

$wsdl="http://localhost:8280/services/HelloNuSOAP?wsdl"; 

是來自WSO2ESB的WSDL地址。 我們稱之爲「請求超時」的結果爲

如果我們改變與在服務代碼放置取服務的服務器直接WSDL地址,讓我們說

$wsdl="http://localhost/ws/hello_serper_nusoap.php" 

結果服務器將成功地調用,我們會擁有一個結果

因此,我們可以得出WSO2ESB無法調用該PHP Web服務的結論。有沒有辦法在WSO2ESB上調用php web服務?

+0

我們能看到你的代碼,請 – Satya

+0

好..我已經加了我的代碼..謝謝.. –

回答

0

哇..我解決了我的問題上面..!

唯一的原因是因爲我的PHP服務正在IIS服務器上運行。

我已經嘗試將我的服務器更改爲Apache(使用wamp)..然後通過WSO2ESB使用SOAPUI訪問它。

然後..

中提琴... WSO2 ESB閱讀PHP服務成功沒有任何問題。如果使用PHP客戶端,我只需添加我的PHP客戶端和PHP cURL Extension即可訪問它。

我不知道IIS和WSO2ESB之間會發生什麼。希望它可以用於其他人。

謝謝。