22 Building SOA-based Solutions for IBM System i Platform
3.4 Web services description: WSDL
A WSDL document describes a Web service: Web service location, methods, and method
parameters. Example 3-4 shows a sample JavaBean implementation. Notice that this Web
service has one method convertTemp that has an input String parameter and output String
Example 3-4 Sample JavaBean implementation
public class TempConversionService {
public String convertTemp(String tempIn){
Double tempFahrenheit = new Double(tempIn);
// Convert temperature
Double tempCelsius = new Double ((5/9)*(tempFahrenheit.doubleValue()-32));
// Return a String value
return tempCelsius.toString();
Example 3-5 shows a WSDL file that the WebSphere Development Studio client for iSeries
Web services wizard generated for this JavaBean. While the document can seem
complicated at a first glance, you can still see familiar elements from the Web service
implementation: Web service method name and parameter definitions. At the end of the
document you find the following Web services location:
<wsdlsoap:address location=
Notice that the generated URL points to localhost. This URL is the only part of the WSDL
document that you need to change before deploying the Web service to the server and
sending WSDL to the Web service client developer. You need to replace localhost and the
default port with the host name of your server and WebSphere Application Server port.
Example 3-5 Sample WSDL file
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://services.ibm.com"
xmlns:impl="http://services.ibm.com" xmlns:intf="http://services.ibm.com"
<schema targetNamespace="http://services.ibm.com"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://services.ibm.com"
xmlns:intf="http://services.ibm.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
<element name="convertTempResponse">
<element name="convertTempReturn" nillable="true" type="xsd:string"/>
Chapter 3. Web services technology stack 23
<element name="convertTemp">
<element name="tempIn" nillable="true" type="xsd:string"/>
<wsdl:message name="convertTempRequest">
<wsdl:part element="impl:convertTemp" name="parameters"/>
<wsdl:message name="convertTempResponse">
<wsdl:part element="impl:convertTempResponse" name="parameters"/>
<wsdl:portType name="TempConversionService">
<wsdl:operation name="convertTemp">
<wsdl:input message="impl:convertTempRequest" name="convertTempRequest"/>
<wsdl:output message="impl:convertTempResponse"
<wsdl:binding name="TempConversionServiceSoapBinding"
<wsdlsoap:binding style="document"
<wsdl:operation name="convertTemp">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="convertTempRequest">
<wsdlsoap:body use="literal"/>
<wsdl:output name="convertTempResponse">
<wsdlsoap:body use="literal"/>
<wsdl:service name="TempConversionServiceService">
<wsdl:port binding="impl:TempConversionServiceSoapBinding"
The WSDL file is sometimes called a
contract between a Web service and a Web service
client. After you create a contract, your goal should be not to introduce any changes to it.
Otherwise, the communication between a Web service client and a Web service will be
broken. You
can change Web service implementation (for example, change the way you
calculate temperature conversion). However, if you change your method of signature (method
name or parameter types), you will break the contract. Changing Web service location will not
break the contract. Just remember to notify the Web service client of Web service URI

Get Building SOA-based Solutions for IBM System i Platform now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.