PHP5 Soap Server
Saturday, January 19. 2008
I’m glad you found my posts helpful.
Great follow-up post. I’m glad you emphasized that the WSDL is best read from end to beginning. Once I discovered that, it made writing/modifying WSDLs much easier.
Jimmy Z: Thanks for dropping by, your posts were very helpful and there is very little else out there on this topic.
Hi Lorna Jane,
Thanks for all this – the info on PHP and Soap on the Net is a total mess. Some choosing to to use nusoap.php – which now doesnt even exist anymore. Great work using this method I was up and running very quickly.
However – this method only shows a call passing one parameter. What needs to change inorder for the server to accept more than one parameter from the client ?
Kind Regards,
Tyrone.
Just wanted to add that if you encounter connection problems to the server when using localhost then change "localhost" in the WSDL to "127.0.0.1".
I could not figure out how to add a second function to the WSDL file. I always get an error when I want to call the second function. Could someone post an example please?
Nik: I can’t imagine what a wsdl would look like pasted into here so I’ve put it in a separate file for you, I’ve included another example soap function so you can see the wsdl with two functions and I hope this will give you the help you need. The wsdl is at http://web.lornajane.net/sugar_soap_doc/example.wsdl – post again if you have more questions!
There should be an easier way to generate the wsdl file. Isnt there any tool to do so. I am finding it diificult to get my head around this
Nav: Generating a WSDL is inherently difficult to do properly in PHP – because the language is weakly typed so there is no information about what types each of the variables is expected to be. WSDL on the other hand is really strict, but it requires information that doesn’t exist in PHP! I’ve seen some fairly good attempts at WSDL generation, but nothing that is either painless or simple. I’d love it is anyone could tell me otherwise though …
Zend Framework has a decent solution to auto-generating a WSDL file for a particular class.
Basically they use developer created php-doc comments to determine the correct data types.
http://framework.zend.com/manual/en/zend.soap.html
Their XML-RPC class is pretty good as well.
Andrew: Thanks for your comment – I had trouble getting the ZF version of the WSDL generator to work, but that was a couple of versions ago and I’d certainly give it another try if I had to do it again.
Just to add on to this thread for posterity — you can also use the Webservice Helper tool from http://www.jool.nl/new/
This is a web application which lets you build your service using a class -> WSDL method, instead of the other way around.
I had the SOAP service up and running in about half an hour using this tool. Very handy.
Thank you for the useful article. After looking at numerous on-line tutorials and spending many hours testing code, your article, along with pointer to Jimmy Z’s article/code, resulted in getting a basic web service running in 30 minutes. Thanks again!
Matthew: I’m really happy to hear that this post helped you get your web service up and running so quickly – thanks for commenting :)



I write on technical subjects on this site on a fairly regular basis, and nothing annoys me more than blog software which "eats" long lines of code or renders it in a difficult-to-read way. Happily Serendipity (or s9y for short) has a plugin for geshi.
Tracked: Mar 24, 13:11
I recently had reason to write a REST server in PHP , which was very interesting. There aren’t a whole lot of resources on this topic around so I thought I’d write an outline of what I did. There is quite a lot to it so I’m publishing in multiple section
Tracked: Aug 31, 20:19