This experiment explores the language bindings for a simple WSDL file where three parameters are varied:
document
vsrpc
for thesoap:binding/@style
andsoap:operation/@style
attributes.literal
vsencoded
for thesoap:body/@use
attributeselement
vstype
attributes of themessage/part
elements
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) {
}