简体   繁体   中英

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.

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

I was looking for the same functionality, but it's look like it does not exist like this for a server side.

After, you can just use a script as wsdl2php to generate the client side classes, and just use the classes for info and respond part it creates... Then you'll use a SoapServer declaration as noetix propose.

There is a good presentation of wsdl2php on this site : http://www.dimuthu.org/blog/2008/09/21/wsdl2php-2-minutes-introduction/

If someone know a script to generate the server side, I'm still interested :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM