An old web service implemented in PHP have been giving me some headache the last couple of days. Especially interoperability with clients implemented in other languages (like .NET) are troublesome. It seems to me that PHP is very forgiving. Which is good – sometimes – but not always. PHP let you get away with a lot when creating your web services. So just because your PHP client play along nicely doesn’t mean other clients will work. Far from it.
So after loads of googling I came to realise that even though 2010 is just around the corner there are still very few quality articles on PHP and web services/SOAP available. Most of the stuff I find is rubbish where people who don’t know nothing explain things they don’t understand.
So even though these articles below are old, they will give most people a very good grasp on how, and why, to create a SOAP web service using PHP that will work. (And a very short advice; use document/literal style for better interoperability with for example .NET and don’t use preserved words like “ref” as parameter (message parts) names for better interoperability with for example .NET).
A comment about the second article is in place though. I generally tend to favour mapping WSDL defined operations to methods in a class. So instead of using PHP methods like $server->addFunction(), use $server->setClass(). More on setClass() in the manual.