简体   繁体   English

如何使用WSO2 ESB调用外部PHP Web服务

[英]How to Invoke External PHP Web Services with WSO2 ESB

Hello WSO2 ESB community, 您好WSO2 ESB社区,

I have a services in PHP. 我有PHP服务。 I have invoked into WSO2ESB through WSDL proxy and no problem with that. 我已经通过WSDL代理调用到WSO2ESB中,这没有问题。 But, when I tried to call it from either SOAP client or 'try this services' built in WSO2ESB, that services can't be called and show an error : 但是,当我尝试从SOAP客户端或WSO2ESB中内置的“尝试此服务”调用它时,无法调用该服务并显示错误:

org.apache.axis2.AxisFault: Read timed out org.apache.axis2.AxisFault:读取超时

Can you help me what's wrong..? 你能帮我怎么了..? As a note, that's PHP services is goes well when call directly from SOAP client, not through WSO2ESB.. 注意,直接从SOAP客户端而不是通过WSO2ESB进行调用时,PHP服务运行良好。

this is my PHP services code.. 这是我的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);
?>

** **

and the client look like this one.. 客户看起来像这样

<?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>';
    }
}

?>

on the part of client code, 在客户代码方面,

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

is WSDL address from WSO2ESB. 是WSO2ESB的WSDL地址。 The result when we called it is "request time out" . 我们称其结果为“请求超时”

If we change that with direct WSDL address from services server where the services code take placed, let's say 如果我们使用放置了服务代码的服务服务器的直接WSDL地址来更改此地址,则可以说

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

the result is server will be invoked succesfully and we'll got a result . 结果是服务器将被成功调用,我们将得到一个结果

So, we can make a conclusion that WSO2ESB can't call that PHP web services. 因此,我们可以得出一个结论,即WSO2ESB无法调用该PHP Web服务。 Is there any way to invoke php web services on WSO2ESB? 有什么方法可以在WSO2ESB上调用php Web服务吗?

Wow.. i have resolved my problem above..! 哇..我已经解决了我的问题..!

the only one cause is because my PHP services is running on IIS server . 唯一的原因是因为我的PHP服务正在IIS服务器上运行

I have tried change my server to Apache (with wamp).. then access it with SOAPUI through WSO2ESB. 我尝试将服务器更改为Apache(带有wamp)..然后通过WSO2ESB用SOAPUI访问它。

Then.. 然后..

Viola... WSO2 ESB read that PHP services successfully without any problem. 中提琴... WSO2 ESB读到PHP服务成功,没有任何问题。 I only should add my PHP client with PHP cURL Extension to access it if PHP client will be used. 如果将使用PHP客户端,则仅应添加带有cURL Extension的PHP客户端以访问它。

I don't know what happen between IIS and WSO2ESB. 我不知道IIS和WSO2ESB之间会发生什么。 Hopefully it can useful for others. 希望它对其他人有用。

Thank You.. 谢谢..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM