Home » Php » php web service example

php web service example

Posted by: admin April 23, 2020 Leave a comment


I am new to web services. I would like to get a good tutorial and example for web service using PHP. Please suggest to me some websites that explain these things in a simple way.

Thank you…

How to&Answers:

Here are some links to get you started:




This is what you need.

Make sure you habe Zend Framework installed – it says how to install it if you don’t have it, anyway.

The good thing about it is that it allows Discovery – the rest of the tutorials on the net don’t are basic POST/GET – no discovery of services.

ini_set('include_path', '/usr/share/php/libzend-framework-php/');
require_once 'Zend/Soap/AutoDiscover.php';
require_once "Zend/Soap/Server.php";

class BogdansInjectData {

 private $quotes = array(
    "one" => "answer one");  

   * @param string $quote
   * @return string

  function PushData($quote) {
    /* just encase the string is in uppercase*/
    $symbol = strtolower($quote);
    /* if there is a quote for the day requested */
    if (isset($this->quotes[$quote])) {
      return $this->quotes[$quote];
    } else {
      /* else error */
      throw new SoapFault("Server","Unknown Symbol '$quote'.");

// if(isset($_GET['wsdl'])) {

$autodiscover = new Zend_Soap_AutoDiscover();



PS: Follow this post as it’s the source for the solution and it’s constantly updated: http://www.getcomputerservices.co.uk/web-development/php-web-service-with-microsoft-discovery/


Here’s a simple example that may help you get started:


And here’s a slightly more complicated example:

Php webservice that takes JSON via POST and spits back an image


I use this source code. Its a SOAP example: http://www.java2s.com/Code/Php/Web-Services-SOAP-WSDL/CatalogWeb-Services-SOAP-WSDL.htm