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.

2 Answers 2

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: https://www.php.net/manual/en/soapserver.soapserver.php & https://www.php.net/manual/en/soapserver.setclass.php

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.