Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate SoapServer from WSDL in PHP

I have a WSDL generated by a webservice in java, and I need to replicate this same web service in a php application.

I looked, and most scripts I found just generate the client. And I need server side that will be consumed.

like image 814
Fabio Avatar asked Oct 18 '12 03:10

Fabio


People also ask

What is WSDL PHP?

WSDL stands for Web Services Description Language.

Is WSDL XML?

WSDL is an XML notation for describing a web service. A WSDL definition tells a client how to compose a web service request and describes the interface that is provided by the web service provider.


1 Answers

If you have the WSDL then you can simply pass it to the SoapServer class defined in PHP5.

$server = new SoapServer("some.wsdl");
$server->setClass('MySoapServer');
$server->handle();

Of course, you'll need to write the MySoapServer class to handle the methods as defined in your WDSL to make this example work.

For example, if the WDSL defined an add($a, $b) function, the class would be like so:

class MySoapServer
{
    public function add($a, $b)
    {
        return $a + $b;
    }
}

Source: http://au1.php.net/manual/en/soapserver.soapserver.php & http://au1.php.net/manual/en/soapserver.setclass.php

like image 76
noetix Avatar answered Oct 04 '22 00:10

noetix