Working with X-Fire soap services and inheritance in PHP

A while ago we started using X-Fire for soap services. The new soap services we created used inheritance in the returned classes, which wasn’t really that straight forward to implement in PHP. Let’s say we have a abstract class Person, which holds whatever common data we need to have about a person. In addition there are two sub-classes of Person called Runner and Madman. The runner holds info about max speed while the madman has a insanity score (I rock at examples!).

I set up three classes in PHP called MyPerson, MyMadman and MyRunner. MyMadman and MyRunner inherits MyPerson. The class map was set up to map Person to MyPerson, Madman to MyMadman and Runner to MyRunner. This worked like a charm for retriving data that was sent from the backend. A madman came over the wire as a Person with xsi:type set to Madman. The problems started when I was supposed to send a Madman back over soap. Let’s call the method GiveCake(Person p, string cake). The soap side expected any kind of Person to arrive. First I tired just sending a Madman with a delicious cake title, but to my surprise that didn’t work at all. The problem is that the object was sent as a Person with the Madman taggs added, but with no xsi:type to tell the soap server that this in fact was a Madman. After looking all over for hints on how make this work I came across SoapVar. Thef following one-liner solved the problems: $soapObject = new SoapVar($obj, XSD_STRING, “$class_name”, $namespace). Class name is the xsi:tag here.



  1. March 17, 2008 at 2:26 pm

    […] Working with X-Fire soap services and inheritance in PHP […]

  2. March 17, 2008 at 5:47 pm

    […] Working with X-Fire soap services and inheritance in PHP […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: