Zend
  Home arrow Zend arrow Page 6 - PHP SOAP Extension
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ZEND

PHP SOAP Extension
By: Zend
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 18
    2004-03-17

    Table of Contents:
  • PHP SOAP Extension
  • A First SOAP Client
  • Using WSDL
  • A First SOAP Server
  • Creating the Server
  • Example 6
  • Example 8 (client5.php)
  • Other Implementations of SOAP for PHP

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    PHP SOAP Extension - Example 6
    (Page 6 of 8 )


    A modified version of our SOAP server and client follows:

    Example 6 (server2.php)


    <?php
    class QuoteService 
    {
      
    private $quotes = array("ibm" => 98.42);  
      function 
    getQuote($symbol) {
        
    if (isset($this->quotes[$symbol])) {
          
    return $this->quotes[$symbol];
        
    } else {
          
    throw new SoapFault("Server","Unknown Symbol '$symbol'.");
        
    }
      
    }
    }
    $server = new SoapServer("stockquote2.wsdl");
    $server
    ->setClass("QuoteService");
    $server
    ->handle();
    ? >

    As you can see, I have used the SoapServer::setClass() method to connect the SoapServer object with the QuoteService class.

    Example 7 (client4.php)


    <?php
      $client 
    = new SoapClient("stockquote2.wsdl");
      
    try {
        
    echo "<pre>n";
        
    print($client->getQuote("ibm"));
        
    echo "n";
        
    print($client->getQuote("microsoft"));  
        
    echo "n</pre>n";
      
    } catch (SoapFault $exception) {
        
    echo $exception;   
      
    }



    What’s inside?
    Are you curious about the SOAP message format, or hoping to debug a SOAP client of your own? If so, this section is for you.
    The SoapClient() constructor accepts an associative array as its second parameter, as you already saw in the first example. Various options can be passed through this associative array. Here are just two:
    • trace – allows the client to store SOAP requests and responses (turned off by default)
    • exceptions – allows the client to control the exception mechanism (turned on by default)
    Take a look at the following SOAP client example. It is derived from example 5, and shows precisely what is transmitted between the client and the server. In order to retrieve this information we use the SoapClient methods __getLastRequest() and __getLastResponse().

    More Zend Articles
    More By Zend


     

       

    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

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway