PHP Web Services With Soap


How do you create a web service on ibm i?

You probably know about Scott Klement's web service offerings. Seems complicated. I'm an RPG guy, but I balked at what was involved (no disresect to Scott, I've used his stuff in the past and it's really good). My intuition told me that maybe a better way to accomplish my task was to use "web technologies" like PHP to deal with web services.

We have a client who wants to be able to request that x labels be printed for order y, and who wants to know what those label numbers were.

To transpose into programming tasks: my current mission is (I think) to create a SOAP web service written in PHP that calls a print program on the ibm i, queries the ibm i database and returns that query's result set. That is, we need to accept a request in XML format, call a program on the i, and provide a response, also in XML, that holds the results of the database query.

My expertise is in ibm i and I know a little PHP, so that explains the unlikely (awkward?) mix of technologies.

The Request And Response

The web service should accept an order number, and a quantity that corresponds to the number of labels to be printed for the order. The service must trigger the printing of those labels and return the label numbers that were printed. For example, the request might contain: ABCD123 | 10. The web service needs to create 10 labels for order ABCD123 and return the label numbers that were produced. Label numbers are unique and automatically incremented, you see.

Anyway, my immediate problems were:

  1. How do I even create a web service in PHP?
  2. How will the service accept XML data that includes the request data?
  3. How do I get the PHP to trigger the printing process the on the ibm i?
  4. How do I get the PHP to query the ibm i database with the data I've retrieved from the XML input?
  5. The SQL used to query the ibm i database returns a result set containing a list of label numbers (i.e. an array). How on earth do I get an array into XML format to return to the web service client?

This was a tall order. There is little accurate documentation available to me. I have found that there is plenty of crap on forums and places like stack overflow. There is good information in those places, too, but the ratio of good to bad is not favourable and too much time spent there leads frustration, and that leads to excessive drinking.

I will document the steps involved in, effectively, creating a web service on the ibm i.