7

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.

hakre
  • 193,403
  • 52
  • 435
  • 836
Fabio
  • 109
  • 1
  • 7

2 Answers2

6

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

noetix
  • 4,773
  • 3
  • 26
  • 47
0

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 :)

TytooF
  • 168
  • 8