WSO2 WSF/PHP comes with a comprehensive set of test cases. It covers the most of the basic/concrete scenarios supported by WSF/PHP. You can find these test cases inside the “src/tests” directory of WSF/PHP source package. Or you can find the latest test-suite from the SVN location.
You have to have the ‘pear’ utility tool comes with PHP. And add this to the PATH environment variable.
Copy the samples and src/tests/samples/services directory (paths are relative to the root directory of the wsf/php package) to the web root directory.
Then go to the src/tests directory and execute the following command.
pear run-tests -r
This will execute all the test cases under the ‘tests’ directory and finally give a summery of the test results.
You can run individual test cases separately by providing the relative path to the test case from the ‘test’ directory. E.g. To run the echo_client.phpt test case, you may type
WSDL Caching is first introduced with the WSF/PHP 2.0.0 release to optimize the response time of PHP web services. In WSDL Caching WSF/PHP keeps an intermediate XML model which is generated from the WSDL in memory. This intermediate model which we call as ‘SIG’ or ‘Signature’ model is generated at the first request to the service. This SIG can be generated using an XSLT template from any WSDL 2.0. So if you provide a WSDL version 1.1, WSF/PHP first convert it to a WSDL 2.0 using another XSLT template and then generate the SIG model. So in generally when WSDL caching is used it avoids two XSLT parses and hence optimize the response time significantly.
In this blog, I will show you a result of some performance tests I did to measure the response time of a service with and without WSDL Caching.
The complete source codes used for the test can be found from here.
Here is a part of the service script I used. It is a simple echo service that echo a string.
// create service in WSDL mode$service = new WSService(array("wsdl" =>"echo.wsdl",
"cacheWSDL" => false, // By default cache WSDL is true"actions" => $actions,
"operations" => $operations));
// getting the start_time$start_time = microtime(true);
// process client requests and reply $service->reply();
// getting the end time$end_time = microtime(true);
// getting the time difference$time_diff = $end_time - $start_time;
logme($time_diff);
You can see in there I have set the “cacheWSDL” to false and log the time taken by the $service->reply() function. Later I have set the “cacheWSDL” to true and measure the time again for the comparison with earlier values.
I have written a client to invoke the service 10 times. And I’m going to measure the time taken do the client request in there.
for($i = 1; $i <= 10; $i ++){// create client in WSDL mode$client = new WSClient(array("wsdl" =>"echo.wsdl"));
// get proxy object reference form client $proxy = $client->getProxy();
// create input object and set values//TODO: fill $input with (data type: string) data to match your business logic$input = "Hello World";
// getting the start_time$start_time = microtime(true);
// call the operation$response = $proxy->myEcho($input);
//TODO: Implement business logic to consume $response, which is of type string// getting the end time$end_time = microtime(true);
// getting the time difference$time_diff = $end_time - $start_time;
logme($time_diff);
echo$response."</br>";
}
Then I have measured the time taken to first 10 request for both WSDL caching on and off scenarios just after starting the Apache server.
If you obvious these values you will figure out when you don’t use WSDL caching it takes same amount of time to server each request. But when you turn on WSDL caching it takes a little more time at the very first request, but the subsequent requests take very low values.
Here is the chart for the above Data, See the Green and White lines corresponding to the WSDL caching turn on, have taken low values. In average we can observe a 50% reduction in server response time with the WSDL caching.
Response Time With and Without WSDL Caching
This result is for a very simple WSDL which only had an echo operation. When the WSDL get more complex and contain lot of wsdl/schema includes and imports, we can expect more optimization due to the WSDL caching. We will check how the complexity of the WSDL affect the performance in a later blog post.:)