rpc/encoded Example - Get Exchange Rate

This section provides a tutorial example on writing a WSDL 1.1 example that uses SOAP 1.1 over HTTP with rpc/encoded as the message style and the encoding option.

"rpc/encoded" is the popular combination of message style and encoding option for most RPC (Remote Procedure Call) Web services. So let's write the second example with:

In this WSDL example, I want to send a SOAP request to call a RPC function to get an exchange rate. The function expects 3 input positional parameters and returns 1 value. So I wrote this WSDL document,

<?xml version="1.0"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

    Copyright (c) 2007 HerongYang.com. All Rights Reserved.

  <wsdl:message name="getExchangeRateInputMessage">
    <wsdl:part name="datePart" type="xsd:date"/>
    <wsdl:part name="fromCurrencyPart" type="xsd:string"/>
    <wsdl:part name="toCurrencyPart" type="xsd:string"/>
  <wsdl:message name="getExchangeRateOutputMessage">
    <wsdl:part name="ratePart" type="xsd:decimal"/>

  <wsdl:portType name="getExchangeRatePortType">
    <wsdl:operation name="GetExchangeRate">
      <wsdl:input name="getExchangeRateInput"
      <wsdl:output name="getExchangeRateOutput"

  <wsdl:binding name="getExchangeRateBinding"
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetExchangeRate">
      <soap:operation style="rpc"
      <wsdl:input name="getExchangeRateInput">
        <soap:body use="encoded"
          parts="fromCurrencyPart toCurrencyPart datePart"/>
      <wsdl:output name="getExchangeRateOutput">
        <soap:body use="encoded" parts="ratePart"/>

  <wsdl:service name="getExchangeRateService">
    <wsdl:port name="getExchangeRatePort"
      <soap:address location=


Note that:

See the next tutorial for testing requests and responses.

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

 Using WSDL Document in Java Apache Axis2/Java for WSDL

 Apache Woden for WSDL Documents in Java

 SoapUI - Web Service Testing Tool

 PHP SOAP Extension for WSDL

 Perl SOAP::Lite for WSDL

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 SoapUI as WSDL 1.1 Testing Tool

WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 SOAP 1.1 Message Styles and Encoding Options

 First Example - Hello

 Request and Response - Hello

 document/literal Example - Guest Registration

 Request and Response - Guest Registration

rpc/encoded Example - Get Exchange Rate

 Request and Response - Get Exchange Rate

 SOAP Body and Operation Name - Book Reservation

 Request and Response - Book Reservation

 elementFormDefault="qualified" - Refill Order

 Request and Response - Refill Order

 encodingStyle="uri" for use="encoded"

 Request and Response - Get Stock Price

 PHP SOAP Extension for WSDL 1.1

 Perl SOAP::Lite for WSDL 1.1

 Apache Axis2/Java for WSDL 1.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

 Archived Tutorials


 Full Version in PDF/EPUB