WsClient->getProxy() way too slow

fschmueser's picture
Hi there, during our testing phase of our cloud service architecture, I had the task to test our services in various programming languages, including php. As we work with ws* services, the WSO2 WSF/PHP seemed like quite a good choice! But with each of our services, I have the same problem: $client = new WSClient(array("wsdl"=>"https://cs-dev.???.com/???.svc?wsdl", "to" => "https://cs-dev.???.com/???.svc","CACert" => "./???/csdev.pem","classmap" => $class_map, "policy" => $policy, "securityToken" => $security_token)); Instantiating the WSClient is no problem, but the next line: $proxy = $client->getProxy(); takes roughly about ten seconds to generate the proxy object. For our purposes, that are approx. 9.5 seconds too much, as I have to instantiate it with every service call. I am aware of the possibility to generate my own client using wsdl2php (just used the online tool until now). But the getProxy() method call logically happens there every time I instantiate the class, too! As I am quite new to php, I wonder, if there is any way to lower that duration or even ged rid of it entirely? Are there any "tricks", I am not seeing with this problem? A little advice would be greatly appreciated to erase the very last issues for a php client implementation for our services! Kind regards! Flo
nandika's picture

Re

This issue comes when your wsdl is a very complex one. You can try the wsdl caching option. Regards Nandika
keye.liu.gmail.com's picture

Somebody reported this on

Somebody reported this on SoapClient. http://wso2.org/forum/thread/4743 Is there any fix for WSClient->getProxy()? It takes about 20 seconds to generate response on my case. My WSDL is very simple. There is only one class with one function with "hello, world".
keye.liu.gmail.com's picture

I even tried wsdl (xml file)

I even tried wsdl (xml file) directly. It is still slow. Is there anyway to set cache? I looked at the API, there seems no parameter for this.
nandika's picture

Re

wsdl caching support is not available for the client side for the moment. However, service side caching is available. You can enable it with the option "cacaheWSDL"= true | false in the WSService constructor. Regards Nandika
sbarnoud's picture

It takes between 5 and 7

It takes between 5 and 7 seconds for me. If caching isn't possible i will give up.
sbarnoud's picture

Using apc_cache to cache client proxy !

I succeed to cache the client WSDL proxy class using apc_cache (php). I need more testing, but it seems to work. $proxy = apc_fetch("proxyWS"); if ( $proxy === FALSE ) { $client = getClientWS($class_map); $debut = timer(); $proxy = $client->getProxy(); $delai = delai($debut); log_info("Performance getProxy WS : ".$delai,7); apc_store("proxyWS",$proxy); } else { $debut = timer(); $proxy->get_types(); /* Load types */ $proxy->get_functions(); /* Load functions */ $proxy->get_location(); $delai = delai($debut); log_info("Performance getProxy (Cached) WS : ".$delai,7); }
sbarnoud's picture

This is unfortunately not

This is unfortunately not stable. It succeed to cache and reuse some WebService response. But it crashes when reused to call a new WS.
sbarnoud's picture

Change to php_soap extension ...

I successfully tried php_soap extension in wsdl mode. The good surprise is that you still can using wsdl2php output to generate input/output classes! The client overhead which is between 5 and 7 seconds with WSO2 becomes .... 0 ! My client code (the echoString WSO2 client example): <?php class echoString { /** * @var string */ public $inMessage; } class echoStringResponse { /** * @var string */ public $returnVal; } $client = new SoapClient("http://192.168.101.128/WS02/server.wsdl",array("trace" => 0,"exceptions" => 1, 'soap_version'=>SOAP_1_2)); $input = new echoString(); //TODO: fill in the class fields of $input to match your business logic $input->inMessage = $_GET["input"]; try { $response = $client->echoString(new SoapParam($input,get_class($input))); } catch (SoapFault $exception) { echo $exception; } print(" Response is ... ".$response->returnVal); /* If trace is 1 !!!! print "\n"; print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n"; print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n"; print ""; */ ?> As you can see, there isn't a lot of work to do to switch from WSO2 to php_soap extension ...
cle.clrb.net's picture

Actually, the work done here

Actually, the work done here is pretty trivial. Try getting PHP's Soap_Client to work with WS-Security. You're in a world of hurt there.
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)