Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a PHP soap client code?

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.

like image 629
Meidan Alon Avatar asked Nov 01 '09 09:11

Meidan Alon


People also ask

How can make SOAP call in PHP?

To make SOAP requests to the SOAP API endpoint, use the "Content-Type: application/soap+xml" request header, which tells the server that the request body contains a SOAP envelope. The server informs the client that it has returned a SOAP envelope with a "Content-Type: application/soap+xml" response header.

How do you make SOAP clients?

Go to new project wizard and under Web Service select Web Service Client, click next and then give wsdl file location of your web service. Eclipse will automatically generate web service stubs for you. Show activity on this post.

What is SOAP protocol in PHP?

SOAP stands for Simple Object Access Protocol. SOAP is an application communication protocol. SOAP is a format for sending and receiving messages. SOAP is platform independent.

What is SoapClient?

A SOAP client formulates a request for a service. This involves creating a conforming XML document, either explicitly or using Oracle SOAP client API. A SOAP client sends the XML document to a SOAP server. This SOAP request is posted using HTTP or HTTPS to a SOAP Request Handler running as a servlet on a Web server.


1 Answers

I found generator really useful

https://github.com/wsdl2phpgenerator/wsdl2phpgenerator

Instructions (from github) :

  • Download wsdl2phpgenerator-2.3.0.phar from the latest release
  • Run "php wsdl2phpgenerator-2.3.0.phar -i input.wsdl -o tmp/my/directory/wsdl"

Work for web hosted wsdl too

eg

php wsdl2phpgenerator-2.3.0.phar -i http://someurl/input.wsdl -o tmp/my/directory/wsdl
like image 53
aqm Avatar answered Oct 01 '22 02:10

aqm