Hey! Where’s the Wiz-dill
At the heart of a SOAP conversation is WSDL…the Web Services Definition Language. Now, I’m guessing because PHP is a “mostly” typeless language, the SoapServer extension requires you to provide the WSDL yourself. For the curious, yet uninitiated: WSDL is the definition of what your web service can do. Let’s look a little closer shall we?
For example, you might have a WSDL document that describes your new MicrowaveOven web service. This WSDL document contains the method names, arguments, expected types, etc of your MicrowaveOven.
With this WSDL a SoapClient would know exactly how to ask your $microwaveOven->getTimeRemaining() or be able to $microwaveOven->addMaterial($food). Because all of the conversation’s meta-data is contained in the SOAP Request and Response, it can all happen nearly automatically…depending on your library of choice.
The Brighter Future
Now, if you happen to use .NET or ColdFusion MX, I’m sure you are snickering at the fact we don’t have a WSDL generator. Well, I’m not terribly concerned. Not only is the SoapServer class just getting off the ground, other options in the PHP Community are starting to appear.
For example, if this kind of thing interest you: be sure to keep an eye on Cerebral Cortex. This new PHP 5 framework is looking like an amazing offering. But, of note here are some of the SOAP Web Services Integration pieces. For example, take a look at their examples for their Crtx_SOAP_Server, Crtx_SOAP_AutoDiscover and Crtx_XML_WSDL classes.
The Crtx_SOAP_AutoDiscover uses your phpdoc comments to add the type hinting that is needed for your WSDL. Pretty clever really.
So, what about the SOAP talk?
I think I’ll go ahead and hold off on the Web Services talk until there is some way to have something like (the as yet unreleased) crtx objects make the WSDL for me.
For those of you who were really wanting to see how to write your own service, or query other SOAP services, I don’t want to leave you out in the cold. Zend has written an excellent article (with lots of pretty examples) on PHP 5’s SOAP extension.
Go take a REST
‘Course, you could always take the pragmatic aproach, and look at getting a little REST. It might not be as “cool” as SOAP, but it sure is fast and easy! Don’t decide on your webservices strategy until you have read Adam Trachtenberg’s PHP Web Services Without SOAP
No, go write me some cool webservices to query up against.
Of course, this is a correct statement…but, as Harry points out; only if you don’t take advantage of some of the things OOP helps you do. Of course, even your proceduralists out there could read this and think up ways to implement his ideas in functions…so everyone should at least take a peak.
No image support? no problem…alt property supplied on replace
No JS support? no problem…css marks up your h1 as normal
No visual support? no problem…screen reader reads your h1 or alt tag
Pretty cool in theory. It has built in, server-side cache support, etc. I’m a little squimish about a DoS vulnerability…someone flooding your site with obscene image generation requests. But, that could be trapped. What do you all think?
From Kansas City’s own Alex Leigh:
“I wanted to let you know that I recently wrote an article that perhaps some of your readers would be interested in, which hopefully draws some concern and will provoke some thought about interface design as it relates to the web. The URL is http://www.ashpool.com/strategy/2003/12/webhid/“
I found this web log entry today that I just had to share with you all. If you have the time, I higly recommend reading it. Sure it uses Python for its examples, but the premice is the same. As a PHP user with strongly typed roots…these words really hit home.
Now, if only I can get “Test Infected.”
Thinking About Computing
Bruce Eckel’s Web Log
5-2-03 Strong Typing vs. Strong Testing
Not happy with the street smarts of their legal counsel. When will they learn?