WSDL: RPC vs Document language bindings

Description  #

This experiment explores the language bindings for a simple WSDL file where three parameters are varied: 

Based on these these three binary choices, the Perl script below produces eight different WSDLs from a common template.  Each are then processed with the Apache Axis WSDL2Java utility.  The signatures for both the client and server bindings are then extracted from the resulting Java code.  For brevity, package names and throws clauses are omitted from the resulting output.

In all but two cases, the generated signatures are the same, where the Java types corresponding to the XML schema types are used for the argument and return type.  In the case of encoded element (independent of document vs rpc), a bean with one property is substituted for both the argument and return types.  A heavily elided form of these bean is reproduced below.

Script  #
#!/usr/bin/perl
@classpath = glob("~/jakarta/xml-axis/java/build/lib/*.jar");
push @classpath, glob("~/jakarta/xml-xerces2/java/build/*.jar");
$cp = join(":", @classpath);

@element = qw(element="tns:getQuote" element="tns:getQuoteResponse"); @type = qw(type="xsd:string" type="xsd:decimal");

@base = <DATA>;

for $style (qw(document rpc)) { for $use (qw(literal encoded)) { for $structure ( \(@element,@type) ) { print "$style $use $$structure[0] $$structure[1]\n"; $i++; open OUT, ">test$i.wsdl"; @wsdl = @base; foreach (@wsdl) { s/###style###/$style/; s/###use###/$use/; s/###request###/$$structure[0]/; s/###response###/$$structure[1]/; print OUT; } close OUT;

system "rm -rf test$i"; system "java -cp $cp org.apache.axis.wsdl.WSDL2Java -s -o test$i test$i.wsdl";

$getQuote = `grep getQuote\\(.*\{ test$i/org/stock/*.java`; $getQuote =~ s/java\.\w*\.//g; $getQuote =~ s/org\.stock\.//g; $getQuote =~ s/.*\/(\w*).*(public.*) throws.*/ $1: $2/g; print "$getQuote\n"; } } }

__DATA__ <?xml version="1.0" encoding="utf-8"?> <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://stock.org/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://stock.org/" xmlns="http://schemas.xmlsoap.org/wsdl/">

<types> <xsd:schema targetNamespace="http://stock.org/"> <xsd:element name="getQuote"> <xsd:complexType> <xsd:sequence> <xsd:element name="symbol" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="getQuoteResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="getQuoteResult" type="xsd:decimal" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </types>

<message name="getQuoteSoapIn"> <part name="symbol" ###request### /> </message> <message name="getQuoteSoapOut"> <part name="return" ###response### /> </message>

<portType name="testSoap"> <operation name="getQuote"> <input message="tns:getQuoteSoapIn" /> <output message="tns:getQuoteSoapOut" /> </operation> </portType>

<binding name="testSoap" type="tns:testSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="###style###" /> <operation name="getQuote"> <soap:operation soapAction="http://stock.org/getQuote" style="###style###" /> <input> <soap:body use="###use###" /> </input> <output> <soap:body use="###use###" /> </output> </operation> </binding>

<service name="test"> <port name="testSoap" binding="tns:testSoap"> <soap:address location="http://localhost/service/getQuote" /> </port> </service> </definitions>
Results  #
document literal element="tns:getQuote" element="tns:getQuoteResponse"
  TestSoapImpl: public BigDecimal getQuote(String symbol)
  TestSoapStub: public BigDecimal getQuote(String symbol)

document literal type="xsd:string" type="xsd:decimal" TestSoapImpl: public BigDecimal getQuote(String symbol) TestSoapStub: public BigDecimal getQuote(String symbol)

document encoded element="tns:getQuote" element="tns:getQuoteResponse" TestSoapImpl: public GetQuoteResponse getQuote(GetQuote symbol) TestSoapStub: public GetQuoteResponse getQuote(GetQuote symbol)

document encoded type="xsd:string" type="xsd:decimal" TestSoapImpl: public BigDecimal getQuote(String symbol) TestSoapStub: public BigDecimal getQuote(String symbol)

rpc literal element="tns:getQuote" element="tns:getQuoteResponse" TestSoapImpl: public BigDecimal getQuote(String symbol) TestSoapStub: public BigDecimal getQuote(String symbol)

rpc literal type="xsd:string" type="xsd:decimal" TestSoapImpl: public BigDecimal getQuote(String symbol) TestSoapStub: public BigDecimal getQuote(String symbol)

rpc encoded element="tns:getQuote" element="tns:getQuoteResponse" TestSoapImpl: public GetQuoteResponse getQuote(GetQuote symbol) TestSoapStub: public GetQuoteResponse getQuote(GetQuote symbol)

rpc encoded type="xsd:string" type="xsd:decimal" TestSoapImpl: public BigDecimal getQuote(String symbol) TestSoapStub: public BigDecimal getQuote(String symbol)
Generated Beans  #
public class GetQuote {
    private java.lang.String symbol;
    public java.lang.String getSymbol();
    public void setSymbol(java.lang.String symbol);
}
public class GetQuoteResponse {
    private java.math.BigDecimal getQuoteResult;
    public java.math.BigDecimal getGetQuoteResult() {
    public void setGetQuoteResult(java.math.BigDecimal getQuoteResult) {
}

Essays

Noun vs Verb

Topology

Evolution of the Weblog APIs

Cohesion

SOAP by Example

A Gentle Introduction to Namespaces

Really Simple Syndication

Expect More

REST + SOAP

Beyond Backlinks

Google's Genius

Neuro Transmitters

Headers and Hrefs

A Gentle Introduction to SOAP

Coping with Change

Manufactured Serendipity

Dealing with Diversity

A Busy Developers Guide to WSDL 1.1

Axis/Radio Interop, Actual and Potential

To Infinity and Beyond: the Quest for SOAP Interoperability

What Object Does SOAP Access?

Favorites

In Praise of Evolvable Systems

Metacrap

The Law of Leaky Abstractions

The Eight Fallacies of Distributed Computing

Permanet, Nearlynet, and Wireless Data

Warnock's Dilemma

Sunir's corollaries

Search

Valid XHTML 1.0!