Zend
  Home arrow Zend arrow Page 4 - 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 Developerworks
 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

    Ziff Davis Enterprise Virtual Tradeshows: Hot Topics, Cutting Edge Technology, Real-time Networking among IT Professionals. Learn more

    PHP SOAP Extension - A First SOAP Server
    (Page 4 of 8 )


    Let’s try to write our own SOAP Web service that will do the same as the XMethods “Delayed Stock Quote” service.

    The first task is to create a WSDL document describing our service in a format that client requests will understand. This requires minor modifications to the original document taken from the Xmethods site, so we’ll start by taking a close look at that file.

    The message section defines two messages.  The first is getQuoteRequest, which is a request to relay the getQuote message and takes one string parameter called symbol. The other is getQuoteResponse, which is a response to the getQuote message, containing one float value, named Result.

    The portType section defines one operation, getQuote, which describes which of the messages listed in the message section will be used to transmit the request and response.

    The binding section defines how the messages must be transmitted and encoded. Here it tells us that we will be sending an RPC request using SOAP encoding across HTTP.  It also specifies namespace and value of the SOAPAction header for the getQuote method.

    Lastly, the service section defines the endpoint URL where the service is running.
    Example 3 (stockquote.wsdl)

    <?xml version='1.0' encoding='UTF-8'?>
    <definitions name='StockQuote'
      targetNamespace='http://example.org/StockQuote'
      xmlns:tns=' http://example.org/StockQuote '
      xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
      xmlns:xsd='http://www.w3.org/2001/XMLSchema'
      xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
      xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
      xmlns='http://schemas.xmlsoap.org/wsdl/'>

    <message name='getQuoteRequest'>
      <part name='symbol' type='xsd:string'/>
    </message>
    <message name='getQuoteResponse'>
      <part name='Result' type='xsd:float'/>
    </message>

    <portType name='StockQuotePortType'>
      <operation name='getQuote'>
        <input message='tns:getQuoteRequest'/>
        <output message='tns:getQuoteResponse'/>
      </operation>
    </portType>

    <binding name='StockQuoteBinding' type='tns:StockQuotePortType'>
      <soap:binding style='rpc'
        transport='http://schemas.xmlsoap.org/soap/http'/>
      <operation name='getQuote'>
        <soap:operation soapAction='urn:xmethods-delayed-quotes#getQuote'/>
        <input>
          <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </input>
        <output>
          <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </output>
      </operation>
    </binding>

    <service name='StockQuoteService'>
      <port name='StockQuotePort' binding='StockQuoteBinding'>
        <soap:address location='http://[insert real path here]/stockquote1.php'/>
      </port>
    </service>
    </definitions>

    Note: The WSDL caching feature is on by default. During the development of your WSDL file it should be turned off.

    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




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