views:

686

answers:

3

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.

+5  A: 

You can use the generateProxyCode method instead and save it to a file:

$WSDL     = new SOAP_WSDL($wsdl_url); 
$php      = $WSDL->getProxyCode();
file_put_contents('wsdl_proxy.php', '<?php ' . $php . ' ?>');

require 'wsdl_proxy.php';
Greg
+1  A: 

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

Toran Billups
A: 

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.

Clay Hinson