SOAP Server with PHP5 – part 1 3

Posted by Jimmy'z on February 19, 2007

Setting up a SOAP web service with php used to seem pretty intimidating to me, until I finally decided that I would hunker down and build my own WSDL. Now that I’ve successfully gone through the process of building a SOAP web service with php5, I would say that it really isn’t all that bad. I was actually quite surprised at how easy it was in the end.

To get started, I recommend the PHP Soap Extension article found on the Zend Developer Zone website. Before going through the tutorial you’ll need to make sure that you are running on php 5 with the soap extension installed. If you’re not sure if you are on version 5 or if the SOAP extension is indeed installed, create a script with the following code:

<?php phpinfo(); ?>

That should give you all of your server configuration information that you need. Search that page for “SOAP” and if you find it there with some configuration variables, you’ll know that you’re good to go.

I recommend setting up the SOAP server that is given in the tutorial which requires 3 files: stockquote.wsdl, server1.php, and client3.php. Place those files in a directory that is accessible via http and modify the stockquote.wsdl file, replacing http://[insert real path here]/server1.php with the path to your server1.php file.

Test the service by running the client3.php script. As you modify the service to return more complex data types, you’ll want to change the print function with a print_r to get a dump of the whole data schema that has been returned.

Once you have that working, you can begin to modify the function or WSDL to do what you need it to do.

Important: Before you make changes to the WSDL, add the following line above the client code and at the top of the server1.php script:

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache

Also, in the wsdl there is a part that has urn:xmethods-delayed-quotes. This has nothing to do with stockquotes, and you should just leave it alone.

See part 2 for an explanation of the wsdl.

Trackbacks

Use this link to trackback from your own site.

Comments

You must be logged in to leave a response.

  1. Calles Wed, 28 May 2008 07:03:21 MDT

    Hi my Friend! your information has been helpful. Thank you very much

    I have a doubt, if the method Response of wsdl devulve three values that not is an array, as I can manipulate that in the function of the served?

  2. Now talking! Sun, 01 Mar 2009 23:29:02 MST

    The benefits of SOAP…

    I just recently got interested on SOAP. This will make a huge improvement on how I scale my applications using PHP and ASP.NET.
    Thanks for the article from Jimmy (trackback).
    ……

  3. Webservices mit PHP « RL Design | Blog Wed, 03 Mar 2010 16:39:14 MST

    [...] Einstieg in die Webservice Programmierung mit PHP zu erhalten ist dieser (englischsprachige) Blog Artikel von JimmyZ sehr zu [...]