September 21st, 2008WSDL2PHP 2 Minutes Introduction
WSDL2PHP makes the development of web service providers and consumers quick and easy. I wrote a 2 minutes guide on developing web services providers sometimes ago. So lets concentrate on developing web service consumers here.
Where is WSDL2PHP?
WSDL2PHP script is included in the WSF/PHP packs. You can find the wsdl2php.php script inside the ’scripts’ directory of any source or binary package. Or you can use the online wsd2php tool hosted in WSF/PHP web services DEMO Site.
How to Run the Script?
Here is the command
/scripts/wsdl2php.php mywsdl.wsdl > myclient.php
The Code is Generated. How Can I add My Code There?
It is simple. Just search for the comment “//TODO”.
Check for an example here.
You have to write custom code for 2 occasions per operation.
- To Provide Input Parameters
- To Handle output parameters.
An Example?
Here is the code snippet corresponding to the simpleAdd request for our demo WSDL.
$input = new simpleAdd(); //TODO: fill in the class fields of $input to match your business logic // call the operation $response = $proxy->simpleAdd($input); //TODO: Implement business logic to consume $response, which is of type simpleAddResponse
Here is how after I filled my logic in place of TODO comments.
$input = new simpleAdd(); //DONE: fill in the class fields of $input to match your business logic //-------my code---- $input->param0 = 2; $input->param1 = 3; //------------------ // call the operation $response = $proxy->simpleAdd($input); //DONE: Implement business logic to consume $response, which is of type simpleAddResponse //--------my code----- echo $response->return; //--------------------
![[Ask]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/ask.png)
![[Bloglines]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/bloglines.png)
![[del.icio.us]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/digg.png)
![[diigo]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/diigo.png)
![[dzone]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/dzone.png)
![[Facebook]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/google.png)
![[MySpace]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/myspace.png)
![[MyWeb]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/myweb.png)
![[Newsvine]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/newsvine.png)
![[PlugIM]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/plugim.png)
![[Reddit]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/reddit.png)
![[Slashdot]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/slashdot.png)
![[Spurl]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/spurl.png)
![[StumbleUpon]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Twitter]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/twitter.png)
![[Windows Live]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://www.dimuthu.org/wp-content/plugins/bookmarkify/email.png)