Is there a way to generate a PHP Soap Client from a WSDL file?
I mean something like wsdl.exe
or svcutil.exe
in .net, that generates code for a class that can be the client of a service, not something like:
$WSDL = new SOAP_WSDL($wsdl_url);
$client = $WSDL->getProxy();
My problem is that I want the PHP client to be able the work with a service, even when that service doesn't expose its WSDL.
Just to help anyone else who comes across this post and thinks "how the heck do I work w/ this SOAP_WSDL thing?" (like myself)
Open the command line and get to your php directory (I installed XAMPP Lite in this example)
Once in the php directory I ran the pear.bat script. After this I was able to type the following via cmd line
pear -V (provides the version of your install)
pear list
If you type the above and don't see SOAP you need to do the following from the cmd line:
pear install Net_DIME-1.0.1
pear install Mail_Mime-1.5.2
pear install Mail-1.2.0b1
pear install SOAP-0.12.0
Now after you install these packages and do another "pear list" you should see SOAP listed.
If so you can include a reference to the php files pulled down inside the pear directory under SOAP.
One example of this path might be C:\xampplite\php\PEAR\SOAP
I used wsdl2php, a simple PEAR tool; it seems that project is dead, but you can still download the latest version here: http://sourceforge.net/projects/wsdl2php/
It require a development machine with PHP 5 and PEAR, and you have to install it with this PEAR command:
After this, you can generate the PHP classes file with this command:
It generates a main class that extends SoapClient, and many other classed that represent requests, responses, and complex objects, so it is very useful when developing in a IDE with "intellisense" like NetBeans.
I found generator really useful
https://github.com/wsdl2phpgenerator/wsdl2phpgenerator
Instructions (from github) :
Work for web hosted wsdl too
eg
There is an app for this, it's called wsdl2phpgenerator:
http://code.google.com/p/wsdl2phpgenerator/
Run it against a WSDL file and it will generate classes based on the WSDL services.
I've tried to use everething that were listed here.
Found the another choise: https://github.com/mikaelcom/WsdlToPhp
Pluses in comparition with previous:
No dependencies. Both for generator and created client.
Classes for in and out parameters.
Examples of using for created client. It's course not so important. But some times very useful
Less of code (In comparision with SOAP_WSDL)
Minuses:
You can use the method [
generateProxyCode
] provided in the package SOAP_WSDL (http://pear.php.net/reference/SOAP-0.9.4/SOAP/SOAP_WSDL.html#methodgenerateProxyCode) method instead and save it to a file: