Home arrow Zend arrow Page 2 - PHP SOAP Extension

A First SOAP Client - Zend

This article describes the new SOAP extension for PHP. It is intended for PHP developers who want to write their own Web Services servers, or use SOAP to access existing ones. It assumes some familiarity with Web Services, SOAP, and WSDL (Web Services Description Language).

TABLE OF CONTENTS:
  1. PHP SOAP Extension
  2. A First SOAP Client
  3. Using WSDL
  4. A First SOAP Server
  5. Creating the Server
  6. Example 6
  7. Example 8 (client5.php)
  8. Other Implementations of SOAP for PHP
By: Zend
Rating: starstarstarstarstar / 23
March 17, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

To demonstrate how to make a simple SOAP Client, we’ll take the XMethods demo service, “Delayed Stock Quote”, as our target. Before we start to write any PHP code, we’ll need to gather some information about this particular service:
  • The method name
  • The endpoint URL where the service is running
  • The SOAPAction header value for the method
  • The namespace URI for the method
  • Input and output parameter names and types

Happily, all this information is available on the XMethods web site at http://www.xmethods.com/ in the form of the service’s RPC profile:

Method Name getQuote
Endpoint URLhttp://66.28.98.121:9090/soap
SOAPActionurn:xmethods-delayed-quotes#getQuote
Method Namespace URIurn:xmethods-delayed-quotes
Input ParametersSymbol                      | String
Output ParametersResult                        | float


Example 1 (client1.php)


<?php
  $client 
= new SoapClient(NULL,
    
array(
      
"location" => "<A href="http://66.28.98.121:9090/soap">http://66.28.98.121:9090/soap</A>",
      "uri"      => "urn:xmethods-delayed-quotes",
      "style"    => SOAP_RPC,
      "use"      => SOAP_ENCODED));
  print($client->__call(
    /* SOAP Method Name */
    "getQuote", 
    /* Parameters */
    array(
      new SoapParam(
        /* Parameter Value */
        "ibm", 
        /* Parameter Name */
        "symbol")),
    /* Options */
    array(
      /* SOAP Method Namespace */
      "uri"        => "urn:xmethods-delayed-quotes",
      /* SOAPAction HTTP Header for SOAP Method */
      "soapaction" => "urn:xmethods-delayed-quotes#getQuote")). "n");
? >


As you can see, this simple task required a lot of work.
Fortunately, Web Services can describe themselves to the client using WSDL, and generally they achieve this successfully. The location of the WSDL document for the XMethods “Delayed Stock Quote” service is given on the information page for that service at xmethods.com.



 
 
>>> More Zend Articles          >>> More By Zend
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

ZEND ARTICLES

- Taking the Zend Certified PHP Engineer Exam:...
- Quick Introduction to PHP 5
- PHP SOAP Extension
- Improving Performance
- PDFs with PHP part 2
- PDFs with PHP part 1
- PHP at Lycos
- Build Database Interfaces

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: