Hi, The company I work for are looking into creating an API for their clients and I have set off on the task on researching what the best approach is. Only to find out after a bit of discussion, I'm to use SOAP. I've got my head around the SoapClient class and fairly confident I can get that side working. What I'm having troubles with is the SoapServer and the creation of WSDL files. I've been searching round the internet for about 2 hours now looking for a descent tutorial, or even just any information on how it all ties together with no joy. Can any one explain to me how WSDL files are created, and if it's possible, how to generate them while using SoapServer. Cheer.
WSDL isn't too bad, once you get your head around it.... (who am i kidding.......) http://www.w3.org/TR/wsdl You're not going to find a much better resource than that, but to be fair, its a lot to take in. Basically, the WSDL is a resource to identify the services provided. If you are using the PHP SOAP server class, then functionality isnt built in by default. [for reference] http://php.net/manual/en/book.soap.php http://www.php.net/manual/en/soapserver.getfunctions.php There are some workarounds to this however; you can create your own class to do this, but any errors in the WSDL will cause you more grief than it's probably worth. There are quite a few other work arounds offered elsewhere, such as; http://www.brainbell.com/tutorials/php/Creating_A_Web_Service_With_PHP_5's_SOAP_Extension.htm Im not sure if any of these would be suitable, however, in your scenario. (Of course, this will no doubt become 'a feature' of the php soap lib sooner rather than later)
I've got to admit, this SOAP thing is giving me a headache. I suggested maybe using OAuth instead, but it was dismissed as we've integrated as a client to other SOAP services. Don't suppose you have any suggestions/idea/opinions on what the best approach would be?
If your hands are tied then SOAP it is You should, at the very least, take a look at the WSDL generators mentioned in the above link because they do work, and they aren't overly difficult to get working. (which also means you don't have to go about debugging the WSDL) There are of course a few other ways to implement an API (REST, XMLRPC etc) but it doesn't sound like you are able to use either of those.
I mentioned them in the first reply; since the (built in) PHP SOAP lib does not have a native WSDL generator, you either have to do this yourself, using data returned from the getFunctions call, OR there are some other ways that you can try to generate it for you. Referenced here; http://www.brainbell.com/tutorials/php/Creating_A_Web_Service_With_PHP_5's_SOAP_Extension.htm