The Autoloan service calculates monthly payments for a given loan amount and interest rate. This web service uses document style and literally encoded SOAP messages. Developing a client for this web service is greatly simplyfied since the wsdl2java compiler automatically generated the Java Beans and marshalers for the parameters and return values. The WSDL interface is listed below.
<?xml version="1.0" encoding="utf-8"?> <definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s0="http://circle24.com/webservices/" targetNamespace="http://circle24.com/webservices/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <types> <s:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://circle24.com/webservices/"> <s:element name="Calculate"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="Months" type="s:double" /> <s:element minOccurs="1" maxOccurs="1" name="RateOfInterest" type="s:double" /> <s:element minOccurs="1" maxOccurs="1" name="Amount" type="s:double" /> </s:sequence> </s:complexType> </s:element> <s:element name="CalculateResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="CalculateResult" nillable="true" type="s:string" /> </s:sequence> </s:complexType> </s:element> <s:element name="string" nillable="true" type="s:string" /> </s:schema> </types> <message name="CalculateSoapIn"> <part name="parameters" element="s0:Calculate" /> </message> <message name="CalculateSoapOut"> <part name="parameters" element="s0:CalculateResponse" /> </message> <portType name="AutoloanSoap"> <operation name="Calculate"> <input message="s0:CalculateSoapIn" /> <output message="s0:CalculateSoapOut" /> </operation> </portType> <binding name="AutoloanSoap" type="s0:AutoloanSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <operation name="Calculate"> <soap:operation soapAction="http://circle24.com/webservices/Calculate" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding> <service name="Autoloan"> <documentation>This Web Service mimics a Simple Autoloan calculator.</documentation> <port name="AutoloanSoap" binding="s0:AutoloanSoap"> <soap:address location="http://upload.eraserver.net/circle24/autoloan.asmx" /> </port> </service> </definitions>
If you invoke wsdl2java on the above WSDL document, you can run this client to interact with the service:
package autoloan; import javax.xml.rpc.Stub; import javax.naming.InitialContext; /** To run autoloan in the tcptunnel: tcptunnel 9090 upload.eraserver.net 80 java Client http://localhost:9090/circle24/autoloan.asmx */ public class Client { public static void main(String[] args) throws Exception { | // get the initial context | InitialContext ctx = new InitialContext(); | | // lookup the autoloan service | Autoloan svc = (Autoloan) ctx.lookup("xmlrpc:soap:autoloan.Autoloan"); | | // get an autoloan reference | AutoloanSoap loan = svc.getAutoloanSoap(); | | // set the end point address | if (args.length > 0) { | | Stub stub = (Stub) loan; | | stub._setProperty("javax.xml.rpc.service.endpoint.address", args[0]); | } | | // invoke the service and print result | System.out.println(loan.calculate(24, 8, 15000)); } }
Please refer to the README file for details on how to build and run the example.
Copyright © 2003, 2004 Novell, Inc. All rights reserved. Copyright © 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.