RPC Example - GetStockPrice

This section provides a tutorial example on writing a WSDL 2.0 example that uses SOAP 1.2 over HTTP with RPC as the message style.

My next WSDL 20 example was converted from the WSDL 1.1 version:

In this WSDL example, I want to send a SOAP request to call a RPC function to get a stock price. The function expects 3 input positional parameters and returns 1 value.

<?xml version="1.0"?>
<wsdl:description xmlns:wsdl="http://www.w3.org/ns/wsdl"
  xmlns:wsoap= "http://www.w3.org/ns/wsdl/soap"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:hy="http://www.herongyang.com/Service/"
  targetNamespace="http://www.herongyang.com/Service/">

  <wsdl:documentation>
    GetStockPrice_WSDL_20_SOAP_12_RPC.wsdl
    Copyright (c) 2009 by Dr. Herong Yang, herongyang.com
    All rights reserved
  </wsdl:documentation>

  <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.herongyang.com/Service/">
      <xsd:element name="GetStockPrice">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="Market" type="xsd:string"/>
            <xsd:element name="Stock" type="xsd:string"/>
            <xsd:element name="Date" type="xsd:date"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="GetStockPriceResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="Price" type="xsd:decimal"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>

  <wsdl:interface name="getStockPriceInterface">
    <wsdl:operation name="GetStockPrice"
      pattern="http://www.w3.org/ns/wsdl/in-out" 
      style="http://www.w3.org/ns/wsdl/style/rpc">
      <wsdl:input messageLabel="In" 
        element="hy:GetStockPrice" />
      <wsdl:output messageLabel="Out" 
        element="hy:GetStockPriceResponse" />
    </wsdl:operation>
  </wsdl:interface>

  <wsdl:binding name="getStockPriceBinding"
    interface="hy:getStockPriceInterface"
    type="http://www.w3.org/ns/wsdl/soap"
    wsoap:version="1.2"
    wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
    <wsdl:operation ref="hy:GetStockPrice" 
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response"/>
  </wsdl:binding>

  <wsdl:service name="getStockPriceService"
    interface="hy:getStockPriceInterface">
    <wsdl:endpoint name="getStockPriceEndpoint" 
      binding="hy:getStockPriceBinding"
address="http://www.herongyang.com/Service/GetStockPrice12.php"/>
  </wsdl:service>

</wsdl:description>

See WSDL 1.1 sections for testing requests and responses.

Last update: 2009.

Table of Contents

 About This Book

 Introduction to WSDL 2.0

 WSDL 2.0 Document Structure and Syntax

 WSDL Version 2.0 Part 2: Adjuncts

WSDL 2.0 Document Examples with SOAP Binding

 First Example - Hello

 Multiplart Example - Reservation

RPC Example - GetStockPrice

 WSDL 20 Programming APIs and Testing Tools

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 soapUI 3.0.1 - Web Service Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension in PHP 5.3.1

 Using WSDL in Perl with SOAP::Lite 0.710

 Using WSDL Document in Java with Axis2 1.4.1

 Using WSDL2Java to Generate Web Service Stub Classes

 WSDL 1.1 Binding Extension for SOAP 1.2

 WSDL 1.1 and SOAP 1.2 Examples - Document and RPC Styles

 SOAP 1.2 Binding - PHP, Java and Perl Clients

 WSDL Related Terminologies

 References

 PDF Printing Version