问题
Hello WSO2 ESB community,
I have a services in PHP. I have invoked into WSO2ESB through WSDL proxy and no problem with that. 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 :
org.apache.axis2.AxisFault: Read timed out
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..
this is my PHP services code..
**
<?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. 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="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. Is there any way to invoke php web services on WSO2ESB?
回答1:
Wow.. i have resolved my problem above..!
the only one cause is because my PHP services is running on IIS server.
I have tried change my server to Apache (with wamp).. then access it with SOAPUI through WSO2ESB.
Then..
Viola... WSO2 ESB read that PHP services successfully without any problem. I only should add my PHP client with PHP cURL Extension to access it if PHP client will be used.
I don't know what happen between IIS and WSO2ESB. Hopefully it can useful for others.
Thank You..
来源:https://stackoverflow.com/questions/21956235/how-to-invoke-external-php-web-services-with-wso2-esb