Web Service Foundations: WSDL and SOAP - PowerPoint PPT Presentation

Web service foundations wsdl and soap
1 / 115

  • Updated On :
  • Presentation posted in: Industry

Web Service Foundations: WSDL and SOAP. Marlon Pierce Community Grids Lab, Indiana University mpierce@cs.indiana.edu. What Are Web Services?. Web services framework is an XML-based distributed services system. SOAP, WSDL , UDDI WS-Interoperability

Related searches for Web Service Foundations: WSDL and SOAP

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Download Presentationdownload

Web Service Foundations: WSDL and SOAP

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Web service foundations wsdl and soap l.jpg

Web Service Foundations: WSDL and SOAP

Marlon Pierce

Community Grids Lab, Indiana University


What are web services l.jpg

What Are Web Services?

  • Web services framework is an XML-based distributed services system.


    • WS-Interoperability

    • Intended to support machine-to-machine interactions over the network using messages.

  • Basic ideas is to build a platform and programming language-independent distributed invocation system out of existing Web standards.

    • Most standards defined by W3C, OASIS (IP considerations)

    • Interoperability really works, as long as you can map XML message to a programming language type, structure, class, etc.

      • We regularly use Java-C++ and Java-Perl communication

  • Very loosely defined, when compared to CORBA, etc.

  • Inherit both good and bad of the web

    • Scalable, simple, distributed

    • But no centralized management, not high performance, client applications must be tolerant of failures.

Servlets cgi compared to web services l.jpg

Servlets/CGI Compared to Web Services






















Explanation of previous slide l.jpg

Explanation of Previous Slide

  • The diagram on the left represents a standard web application.

    • Browsers converse with web servers using HTTP GET/POST methods.

    • Servlets or CGI scripts process the parameters and take action, like connect to a DB.

  • On the right, we have a Web services system.

    • Separates visual from non-visual components

    • Interactions may be either through the browser or through a desktop client (Java Swing, Python, Windows, etc.)

Some terminology l.jpg

Some Terminology

  • The diagram on the left is called a client/server system.

  • The diagram on the right is called a multi-tiered architecture.

  • SOAP: Simple Object Access Protocol

    • No longer an abbreviation in SOAP 1.2

    • XML Message format between client and service.

  • WSDL: Web Service Description Language.

    • Describes how the service is to be used

    • Compare (for example) to Java Interface.

    • Guideline for constructing SOAP messages.

    • WSDL is an XML language for writing Application Programmer Interfaces (APIs).

More examples of web services l.jpg

More Examples of Web Services

  • Geographical Information Systems are perfect candidates for WS

    • The Open Geospatial Consortium defines several relevant standards

      • Geographic Markup Language (GML) exchanges info.

      • Web Feature Service works with abstract GML feature data.

      • Web Map Service creates maps (images)

      • Lots more at http://www.opengeospatial.org/specs/?page=specs

  • XMethods

    • Lots and lots of contributed examples, live demos

    • Try them

      • http://www.xmethods.com/

  • Lots more for bioinformatics.

    • Easiest way to find is to download Taverna from SourceForge.

    • Then check out http://communitygrids.blogspot.com for guidelines.

  • CICC is building many new one for chemical informatics.

Rdahmm gps time series segmentation slide courtesy of robert granat jpl l.jpg

RDAHMM: GPS Time Series SegmentationSlide Courtesy of Robert Granat, JPL

GPS displacement (3D) length two years.Divided automatically

by HMM into 7 classes.

  • Complex data with subtle signals is difficult for humans to analyze, leading to gaps in analysis

  • HMM segmentation provides an automatic way to focus attention on the most interesting parts of the time

  • Features:

  • Dip due to aquifer drainage (days 120-250)

  • Hector Mine earthquake (day 626)

  • Noisy period at end of time series

Making rdahmm into a web service l.jpg

Making RDAHMM into a Web Service

  • RDAHMM takes GPS (or other) time-series data as input, along with various command line parameters.

  • GPS data comes from GRWS or other services.

    • http://geoapp.ucsd.edu/scignDataPortal/grwsSummary.jsp

  • It creates 11 output files.

  • Results are superimposed on the input time series.

USAGE: GEMCodes/RDAHMM2/bin/rdahmm -data 'input observation sequence file'

[-L 'output model log likelihood file']

[-Q 'output optimal state sequence file']

[-pi 'output model initial state probability file']

[-A 'output model transition probability file']

[-B 'output model output distribution file']

[-minvalfile 'data minimum value file']

[-maxvalfile 'data maximum value file file']

[-rangefile 'data range file']

[-covarsweightsfile 'covariance component weightings file']

[-covgraphfile 'covariance graph connectivity file']

-T 'number of observations'

-D 'dimension of observations'

-N 'number of model states'

-output_type 'type of HMM output distribution {gauss}'

[-init_type 'type of HMM parameter initialization {random}']


Slide9 l.jpg

This is a portal client to a data mining service that I built. The web service analyzes GPS signal data to look for modes.

The service returns output result files as URLs.

GPS data comes from the Scripps GRWS Web Service. Instead of defining a data type for this file, we just pass around URLs. The RDAHMM service receives the URL as input.

The lesson: don’t go overboard with XML message definitions. You will regret it. Use URLs and keep your SOAP/WSDL simple.

Portal courtesy of NASA REASoN project.

How do you design the rdahmm service l.jpg

How Do You Design the RDAHMM Service?

  • First, you need an engine to run RDAHMM.

    • I develop Java services, so I have found Apache Ant very useful for wrapping binary executables, managing command-lines, and interacting with the Unix shell.

    • You can embed Ant in other Java programs.

  • Second, you need an appropriate Web Service container for your development environment.

    • I use Apache Axis (examples will use version 1.4).

      • This runs in Apache Tomcat.

    • .NET, C/C++, Python, Ruby, Perl, etc all have Web Service containers.

      • Ex: gSOAP for C/C++ from FSU, ZSI for Python

Writing the service l.jpg

Writing the Service

  • Writing a Web Service is easy

    • Just write a Java program

  • In our case, the Java program must

    • Grab GPS data from GRWS service

      • We pass this around using URLs.

    • Collect command line parameter values as input.

    • Run the code.

    • Send back a response as a Java Bean that encapsulates URLs.

      • Can either block or not-block, depending on how you want to execute things.

  • This is a mixture of REST and XML-RPC styles.

Service code example l.jpg

Service Code Example

public RDAHMMResultsBean runNonblockingRDAHMM2(String siteCode,String resource, String contextGroup, String contextId, String minMaxLatLon, String beginDate, String endDate, numModelStates) throws Exception {

try {

String dataUrl=querySOPACGetURL(siteCode, resource, contextGroup, contextId, minMaxLatLon, beginDate, endDate);

return createRDAHMMBean( dataUrl,numModelStates);


catch (Exception ex) {...}


Rdahmmresultbean code l.jpg

RDAHMMResultBean Code

public class RDAHMMResultsBean implements java.io.Serializable {

private java.lang.String AUrl;

private java.lang.String BUrl;

private java.lang.String LUrl;

private java.lang.String QUrl;

private java.lang.String inputUrl;


public RDAHMMResultsBean() {


//Plus all of the getters and setters

public java.lang.String getInputUrl() { return inputUrl; }

public void setInputUrl(java.lang.String inputUrl) { this.inputUrl = inputUrl; }



  • Nothing special about this code.

  • Note all the returned values are actually URLs.

  • AUrl, BUrl, LUrl, etc are all URLs to files generated by RDAHMM.


Deploying an axis 1 service l.jpg

Deploying an Axis 1 Service

  • Now that you have written the code, you follow these steps to make it into a service.

  • Download Axis and install it into Tomcat.

    • That is, create a subdirectory of webapps and put all the Axis jars in WEB-INF/lib/.

  • Create a service descriptor file, service-config.wsdd and put this in WEB-INF/

    • Axis gives you tools to help.

  • Compile your code and put it in WEB-INF/classes or WEB-INF/lib (if jarred).

Creating an axis client l.jpg

Creating an Axis Client

  • Axis will inspect your newly deployed service and create a WSDL file out of it.

    • More on this in a minute.

  • WSDL is an XML API description.

    • It tells clients how to invoke your service.

    • Typically the service is invoked by sending a SOAP message, so WSDL tells you how to construct SOAP.

  • Clients typically discover and download the WSDL (UDDI, wget, whatever).

  • Axis has a tool called WSDL2Java that will convert the WSDL into client stubs.

    • Stubs give you local objects that invoke the remote service.

  • Clients can be anything

    • JSP pages, Java Portlets, PHP clients, Swing or SWT GUIs, etc.

Some notes on axis 2 l.jpg

Some Notes on Axis 2

  • Axis 2 is a redesign of Axis 1 that has

    • Greater performance (usingStAXXML parsers)

    • Extensiblity to support Web Service Quality of Service add-ons.

    • Better support for Java-to-XML binding frameworks.

  • Allows you to send and receive more complicated XML messages.

    • But I think you should avoid this.

  • See my notes:

    • http://communitygrids.blogspot.com/2007/02/some-notes-on-axis2-version-11.html

Some additional notes l.jpg

Some Additional Notes

  • Typically, you don’t need to import any Axis specific packages.

    • Exception: finding and loading a property file.

  • If you are familiar with JSP, servlets, or similar things, you will notice that you also don’t

    • Need to manage HTTP request, response, and session variables.

  • This style of programming is similar to the Inversion of Control Pattern (IOC).

    • Very useful when dealing with Java Beans.

What have we gained from this l.jpg

What Have We Gained from This?

  • We have decoupled the RDAHMM client and the service.

    • Now separated using well-defined interfaces.

    • One service can be used by multiple, independently developed clients.

    • Services just do one thing really well. Application “smarts” are in the client.

  • Multiple services can be linked together into composite applications.

    • Workflow

    • See for example Taverna

      • Google “TavernaSourceForge” to find it.

    • Others: Kepler, XBaya (from IU)

Some general advice l.jpg

Some General Advice

  • Keep you services self-contained with simple interfaces.

    • Core problem in distributed systems is scalability.

    • Services, like mash-ups, are intended to be put to unexpected uses.

    • Complication is the enemy.

    • Services are NOT Distributed Objects

      • http://www.allthingsdistributed.com/historical/archives/000343.html

  • Use XML Simple Types and URLs for input and output rather than attachments.

  • Collect your input/output into Java Beans, C structs, etc, but don’t go overboard.

    • Interoperability can suffer if your I/O types are too complicated.

      • Java<-->C, Axis 1<-->Axis2

    • JavaBeans/POJOs are used frequently in IOC systems like Spring and Java Server Faces.

    • Db4o is a really nice JavaBean database.

Web service extensions l.jpg

Web Service Extensions

  • Web Services communicate with SOAP, and SOAP is designed to be extensible.

  • Examples of Extensions

    • Addressing: describes how SOAP messages can be conveyed across multiple hops.

    • Security: how to authenticate clients and servers, how to authorize usage, etc.

    • Reliability/ReliableMessaging: provides guaranteed delivery through acknowledgements

  • Most of these are defined by specifications published by OASIS.

    • For more discussion, see http://grids.ucs.indiana.edu/ptliupages/presentations/GGF15WebServices/

    • For a critique by Shrideep Pallickara, see http://grids.ucs.indiana.edu/ptliupages/presentations/GGF15WebServices/GGF-Slides.ppt

Wsdl 1 1 overview l.jpg

WSDL 1.1 Overview

Marlon Pierce

Community Grids Lab

Indiana University


What is wsdl l.jpg

What Is WSDL?

  • Web Service Description Language

    • W3C specification

    • See http://www.w3.org/TR/wsdl for the official “note” for WSDL 1.1.

    • WSDL 1.1 never became a full “recommendation”.

    • WSDL 2.0 working draft just completed it’s public call for comments.

  • This slide set will review WSDL 1.1, which is still the “standard”.

    • WSDL 2.0 should replace this soon.

Why use wsdl l.jpg

Why Use WSDL?

  • WSDL uses XML to describe interfaces

    • Programming language independent way to do this.

    • So you can use (for example) C++ programs to remotely invoke Java programs and vice versa.

  • Consider Web browsers and Web servers:

    • All web browsers work pretty well with all web sites.

    • You don’t care what kind of web server Amazon.com uses.

    • Amazon doesn’t care if you use IE, Mozilla, Konqueror, Safari, etc.

    • You all speak HTTP.

  • WSDL (and SOAP) are a generalization of this.

  • Note I will describe WSDL from an Remote Procedure Call/Remote Method Invocation point of view.

    • But WSDL and SOAP also support more a more message-centric point of view.

    • C.f. Java Messaging System.

A very simple example echo l.jpg

A Very Simple Example: Echo

public class echoService implements echoServiceInterface{

public String echo(String msg) {

return msg;


public static void main(String[] args) {

new echoService().echo(“hello”);



The echo interface l.jpg

The Echo Interface


* All implementers of this interface must

* implement the echo() method.


public interface echoServiceInterface {

public String echo(String toEcho);


Now use echo as a remote service l.jpg

Now Use Echo As A Remote Service



  • We can take the previous Java program and deploy it in Tomcat as a service.

  • Clients can then invoke the echo service.

    • WSDL tells them how to do it.

    • Clients don’t need to know anything about the service implementation or even language.

  • WSDL is the latest IDL

    • DCE and CORBA IDL were two older examples.


SOAP(Echo “hello”)





What does echoserviceinterface look like in wsdl l.jpg

What Does echoServiceInterface Look Like In WSDL?

<?xml version="1.0" encoding="UTF-8" ?>

<wsdl:definitions targetNamespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns:intf="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <wsdl:types />

<wsdl:message name="echoResponse">

  <wsdl:part name="echoReturn" type="xsd:string" />


<wsdl:message name="echoRequest">

  <wsdl:part name="in0" type="xsd:string" />


<wsdl:portType name="Echo">

<wsdl:operation name="echo" parameterOrder="in0">

  <wsdl:input message="impl:echoRequest" name="echoRequest" />

  <wsdl:output message="impl:echoResponse" name="echoResponse" />



There’s more…

What does this look like in wsdl continued l.jpg

What Does This Look Like In WSDL, Continued?

<wsdl:binding name="EchoSoapBinding" type="impl:Echo">

<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

<wsdl:operation name="echo">

  <wsdlsoap:operation soapAction="" />

<wsdl:input name="echoRequest">

  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" use="encoded" />


<wsdl:output name="echoResponse">

  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encodingnamespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" use="encoded" />




<wsdl:service name="EchoService">

<wsdl:port binding="impl:EchoSoapBinding" name="Echo">

  <wsdlsoap:address location="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" />




Don’t strain your eyes. We will break this down

Writing wsdl l.jpg

Writing WSDL

  • I’m sure you are impressed with the previous two slides.

  • One could write WSDL by hand, but this is not the usual way.

  • It was automatically generated by Apache Axis. Most other Web service tools will do the same from your service code.

  • We will go through the construction, though, for understanding.

  • You should not think of WSDL (and SOAP) as programming languages.

    • They are just assertions, or descriptions.

Wsdl parts l.jpg

WSDL Parts

  • Types

    • Used to define custom message types

  • Messages

    • Abstraction of request and response messages that my client and service need to communicate.

  • PortTypes

    • Contains a set of operations.

    • Operations organize WSDL messages.

    • Operation->method name, portType->java interface

  • Bindings

    • Binds the portType to a specific protocol (typically SOAP over http).

    • You can bind one portType to several different protocols by using more than one port.

  • Services

    • Gives you one or more URLs for the service.

    • Go here to execute “echo”.

Echo service wsdl section by section l.jpg

Echo Service WSDL, Section by Section

Namespaces l.jpg


  • The WSDL document begins with several XML namespace definitions.

  • Namespaces allow you to compose a single XML document from several XML schemas.

  • Namespaces allow you to identify which schema an XML tag comes from.

    • Avoids name conflicts.

  • See earlier XML lectures

  • As we will see, the Axis namespace generator went overboard.

    • Not all of these are used.

Front matters namespace definitions l.jpg

Front Matters: Namespace Definitions

<?xml version="1.0" encoding="UTF-8" ?>

<wsdl:definitions targetNamespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo"

xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns:intf="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo"


xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"



Wsdl types l.jpg

WSDL Types

Use <types/> to declare local message structures.

What does echoserviceinterface look like in wsdl35 l.jpg

What Does echoServiceInterface Look Like In WSDL?

<?xml version="1.0" encoding="UTF-8" ?>

<wsdl:definitions …>

<wsdl:types />

<wsdl:message name="echoResponse">

  <wsdl:part name="echoReturn" type="xsd:string" />


<wsdl:message name="echoRequest">

  <wsdl:part name="in0" type="xsd:string" />



It’s empty...

Wsdl types36 l.jpg

WSDL Types

  • WSDL messages don’t need to declare types when just sending XML Schema primitive objects.

  • EchoService just has string messages.

    • So no special types definitions are needed in our WSDL.

  • Strings are an XML schema built-in type.

Schema built in types l.jpg

Schema Built In Types

When would i need a custom type l.jpg

When Would I Need A Custom Type?

  • Any time your Web Service needs to send data formatted by anything other than XML Schema built-in types, you must define the type in WSDL.

  • Example: Arrays are not built-in types!

    • Arrays of strings, ints, etc., must be defined in the WSDL <type></type> structure.

  • Another example: JavaBeans (or C structs or any data classes with get/set methods) can be serialized to XML.

    • Pass as messages to the remote endpoint.

    • Support for this in implementations is variable.

      • AXIS has limited support because they use their own serializers.

      • Sun has better support but it won’t work with Axis.

How does wsdl encode string arrays l.jpg

How Does WSDL Encode String Arrays?

  • Imagine that my echo service actually echoes back an array of strings.

  • Arrays are not part of the built-in types, so I will have to define them myself.

  • Luckily for us, SOAP defines arrays, so we can import this definition.

  • Next slide shows what this looks like.

String array example l.jpg

String Array Example


<schema targetNamespace="http://.../GCWS/services/EchoArray"


<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />

<complexType name="ArrayOf_xsd_string">


<restriction base="soapenc:Array">

<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]" />




<element name="ArrayOf_xsd_string" nillable="true" type="impl:ArrayOf_xsd_string" />



Create a new data type, “ArrayOf_xsd_string” that is a restricted extension of the general SOAP array class.

Wsdl string array types l.jpg

WSDL String Array Types

  • WSDL <type/> is nothing more than an extensibility placeholder in WSDL.

  • Technically, the WSDL schema specifies that <type> </type> can contain a <sequence> of 0 or more <any> tags.

    • Look at the WSDL schema.

  • And note that the <any/> tag acts like wildcard.

    • You can insert any sort of xml here.

    • This is a common XML/Web Service trick.

  • Type allows us to strongly type messages

    • Compare: strong versus weak typing in programming languages

Inserting a type l.jpg

Inserting a Type

  • Between <type></type>, we insert a <schema>.

  • Since arrays are defined in SOAP encoding rules, I next import the appropriate schema.

    • I import the definition of the SOAP Array and extend it to a String array.

    • Typically imports also have “location” attributes

      • “This namespace is located here for download.”

  • Next, insert our own local definition of a type called “ArrayOf_xsd_string”.

  • This is a restricted extension of the SOAP Array complex type.

    • We only allow 1 dimensional string arrays

    • It is also nillable—I am allowed to returna “null” value for the string.

Handling other xml types l.jpg

Handling Other XML Types

  • You can also express other message arguments as XML.

    • Examples: a purchase order, an SVG description of an image, a GML description of a map.

  • In practice, these are handled by automatic Bean serializers/deserializers.

    • Castor is an example: http://www.castor.org/

    • XMLBeans is another http://xml.apache.org/xmlbeans/

  • These are tools that make it easy to convert between XML and JavaBeans.

  • By “JavaBeans” I mean objects that associate simple get/set methods with all data.

  • Implementation dependent.

Wsdl messages l.jpg

WSDL Messages

Wsdl messages45 l.jpg

WSDL Messages

  • The “message” section specifies communications that will go on between endpoints.

    • Gives each message a name (to be used later for reference).

    • Specifies the type of message

      • Can be primitive types, like strings

      • Can be defined types, as we saw previously.

The echoserviceinterface messages l.jpg

The echoServiceInterface messages

<?xml version="1.0" encoding="UTF-8" ?>


  <wsdl:types />

<wsdl:message name="echoResponse">

  <wsdl:part name="echoReturn" type="xsd:string" />


<wsdl:message name="echoRequest">

  <wsdl:part name="in0" type="xsd:string" />


<wsdl:portType name="Echo">

<wsdl:operation name="echo" parameterOrder="in0">

  <wsdl:input message="impl:echoRequest" name="echoRequest" />

  <wsdl:output message="impl:echoResponse" name="echoResponse" />




Our echo messages l.jpg

Our Echo Messages

<wsdl:message name="echoResponse">

<wsdl:part name="echoReturn" type="xsd:string" />


<wsdl:message name="echoRequest">

<wsdl:part name="in0" type="xsd:string" />


Echo service messages l.jpg

Echo Service Messages

  • Our echo service takes a string argument and returns a string answer.

  • In WSDL, I first abstract these as messages.

    • Echo needs two messages: request and response

  • Note we have not yet said message is the request and which is the response.

    • That is the job of the portType operations, coming up.

Structure of a message l.jpg

Structure of a Message

  • WSDL <message> elements have name attributes and one or more parts.

    • The message name should be unique for the document.

    • <operation> elements will refer to messages by name.

  • I need one <part> for each piece of data I need to send in that message.

  • Each <part> is given a name and specifies its type.

    • <part> types can point to <wsdl:type> definitions if necessary.

    • Our service just needs xsd:strings, so no problem.

Porttypes and operations l.jpg

PortTypes and Operations

Wsdl porttypes l.jpg

WSDL portTypes

  • WSDL messages are only abstract messages.

    • We bind them to operations within the portType.

  • The structure of the portType specifies (still abstractly) how the messages are to be used.

    • Think of operations-->java methods and portTypes-->java interfaces.

The echoserviceinterface porttype l.jpg

The echoServiceInterface portType

<?xml version="1.0" encoding="UTF-8" ?>


  <wsdl:types />

<wsdl:message name="echoResponse">

  <wsdl:part name="echoReturn" type="xsd:string" />


<wsdl:message name="echoRequest">

  <wsdl:part name="in0" type="xsd:string" />


<wsdl:portType name="Echo">

<wsdl:operation name="echo" parameterOrder="in0">

  <wsdl:input message="impl:echoRequest" name="echoRequest" />

  <wsdl:output message="impl:echoResponse" name="echoResponse" />




Echoservice porttype l.jpg

EchoService portType

<wsdl:portType name="Echo">

<wsdl:operation name="echo" parameterOrder="in0">

<wsdl:input message="impl:echoRequest" name="echoRequest" />

<wsdl:output message="impl:echoResponse" name="echoResponse" />



Porttype message patterns l.jpg

portType Message Patterns

  • PortTypes support four types of messaging:

    • One way: Client send a message to the service and doesn’t want a response.

      • <input> only.

    • Request-Response: Client sends a message and waits for a response.

      • <input>, then <output>

    • Solicit-Response: Service sends a message to the client first, then the client responds.

      • <output>, then <input>

    • Notification: <output> only.

  • These still are abstract. We must implement them using some message protocol.

    • HTTP units of transmission are request and response, so mapping Solicit-Response to HTTP will take some work.

Porttype for echoservice l.jpg

portType for EchoService

  • The echo service has one method, echo.

  • It takes one string argument and returns one string.

  • In WSDL, the portType is “Echo”, the operation is “echo”.

  • The messages are organized into input and output.

    • Messages are placed here as appropriate.

    • That is, <input> takes the <echoRequest> message.

Parameter order l.jpg

Parameter Order

  • This attribute of operation is used to specify zero or more space-separated values.

  • The values give the order that the input messages must be sent.

  • Echo is a bad example, since it only has one input parameter, named in0.

Wsdl self referencing l.jpg

WSDL Self-Referencing

  • The WSDL <input> and <output> tags need to point back to the <message> definitions above:

    <wsdl:message name="echoResponse">

    <wsdl:part name="echoReturn" type="xsd:string" />


    <wsdl:portType name="Echo">

    <wsdl:operation name="echo" parameterOrder="in0">

    <wsdl:output message="impl:echoResponse" name="echoResponse" />



The picture so far l.jpg

The Picture So Far…

Input Message

Input Message







Output Message





Bindings l.jpg


Wsdl soap bindings l.jpg

WSDL SOAP Bindings

  • In the previous slide, we specify several things:

    • We will use SOAP/HTTP

    • We will use RPC encoding style

      • Other choice is literal “document” style.

    • We specify the namespace associated with the Echo service input and output messages.

  • All of this corresponds to SOAP message parts.

    • We will expand this in the next lecture.

Binding section of wsdl l.jpg

Binding Section of WSDL



<wsdl:binding name="EchoSoapBinding" type="impl:Echo">

<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

<wsdl:operation name="echo">

  <wsdlsoap:operation soapAction="" />

<wsdl:input name="echoRequest">


encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo"

use="encoded" />


<wsdl:output name="echoResponse">


encodingStyle="http://schemas.xmlsoap.org/soap/encodingnamespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" use="encoded" />




<wsdl:service name="EchoService">

<wsdl:port binding="impl:EchoSoapBinding" name="Echo">

  <wsdlsoap:address location="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" />




Don’t strain your eyes--we will zoom in.

So far l.jpg

So Far…

  • We have defined abstract messages, which have XML values.

    • Simple or custom-defined types.

  • We have grouped messages into operations and operations into portTypes.

  • We are now ready to bind the portTypes to specific protocols.

The binding for echo l.jpg

The Binding for Echo

<wsdl:binding name="EchoSoapBinding" type="impl:Echo">

<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

<wsdl:operation name="echo">

  <wsdl:input name="echoRequest">



namespace=“[echo service namespace URI]"

use="encoded" />


<wsdl:output name="echoResponse">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

namespace=“[echo service namespace URI]"

use="encoded" />




The highlighted “wsdlsoap:” tags are

extensions for SOAP message binding

and not part of the WSDL schema.

Binding tags l.jpg

Binding tags

  • Binding tags are meant to bind the parts of portTypes to sections of specific protocols.

    • SOAP, HTTP GET/POST, and MIME are provided in the WSDL specification.

  • Bindings refer back to portTypes by name, just as operations point to messages.

    • They are mirror images of the portTypes.

    • Each part is extended by schema elements for a particular binding protocol (i.e. SOAP).

  • In our WSDL bindings, we will have two messages (input and output).

    • Each corresponds to SOAP body sections, described later.

    • Additionally, we specify that the body should be encoded.

      • That is, RPC encoded.

      • Alternatively, could also be “literal” (or “document”).

Wsdl internal references l.jpg

WSDL Internal References









Structure of the binding l.jpg

Structure of the Binding

  • <binding> tags are really just placeholders.

  • They are meant to be extended at specific places by wsdl protocol bindings.

    • These protocol binding rules are defined in supplemental schemas.

  • The following box figure summarizes these things

    • Green boxes are part of WSDL

      • From the wsdl namespace, that is.

    • Red boxes are parts of the document from other schemas

      • From wsdlsoap namespace in the echo example.

Binding structure l.jpg

Binding Structure


Non-wsdl extension


Non-wsdl extension







A little more on encoding l.jpg

A little more on encoding...

  • We specify SOAP encoding

  • SOAP is a message format and needs a transport protocol, so we specify HTTP.

  • Operation styles may be either “RPC” or “Document”.

    • We use RPC.

  • SOAP Body elements will be used to actually convey message payloads.

    • RPC requires “encoded” payloads.

      • Each value (echo strings) is wrapped in an element named after the operation.

      • Useful RPC processing on the server side.

    • Documents are literal (unencoded)

      • Use to just send a payload of XML inside SOAP.

Binding associations to soap l.jpg

Binding Associations to SOAP






SOAP Action





Binding restrictions l.jpg

Binding Restrictions

  • Binding elements point by name to portTypes.

  • WSDL allows more than one binding element to point to the same port type.

    • Why?

    • Because a service may support multiple, alternative protocol bindings.

What does it mean l.jpg

What Does It Mean?

  • WSDL is not a programming language.

  • A service that exposes an WSDL interface is just telling a client what it needs to do to communicate with the service.

    • Send me strings and I will return strings.

    • I expect SOAP messages that include the strings in the body.

    • I expect this body to be RPC encoded with the operation name so that I will know which operation the body contents belong to.

    • I will return SOAP messages that include Strings in the body.

    • These will also be encoded so that you know what to do with them.

Ports and services l.jpg

Ports and Services

What does this look like in wsdl l.jpg

What Does This Look Like In WSDL?





<wsdl:service name="EchoService">

<wsdl:port binding="impl:EchoSoapBinding" name="Echo">

  <wsdlsoap:address location="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" />




Ports and services74 l.jpg

Ports and Services

<wsdl:service name="EchoService">

<wsdl:port binding="impl:EchoSoapBinding" name="Echo">

<wsdlsoap:address location=“http://..../"/>



Port and service tags l.jpg

Port and Service Tags

  • The service element is a collection of ports.

    • That’s all it is for.

  • Ports are intended to point to actual Web service locations

    • The location depends on the binding.

    • For SOAP bindings, this is a URL.

Ports and services76 l.jpg

Ports and Services

  • A service can have more than one port.

  • Two ports can point back to the same binding element.

    • Ports refer to bindings by name

    • This allows you to provide alternative service locations.

  • The figure on next slide conceptually depicts associating two ports to a single binding.

    • The ports differ only in the URLs of their services.

Port associations to bindings l.jpg

Port Associations to Bindings




Port #1


URL #1

Port #2


URL #2

Summary of wsdl l.jpg

Summary of WSDL

  • WSDL decouples remote service operations.

    • Types=custom message definitions.

      • Any data types not in the XML schema.

    • Message=name the messages that must be exchanged and their data types, possibly defined by <type>.

    • PortTypes=service interfaces

      • Operations=remote method signatures.

    • Bindings=mappings of portType operations to real message formats

    • Ports=locations (URLs) of real services.

Soap intro and message formats l.jpg

SOAP Intro and Message Formats

Marlon Pierce

Community Grids Lab

Indiana University


Soap primary references l.jpg

SOAP Primary References

  • SOAP is defined by a number of links

    • http://www.w3.org/TR/soap/

  • See primarily the “Primer” and “Messaging Framework” links.

  • The actual SOAP schema is available from http://www.w3.org/2003/05/soap-envelope/

    • It is pretty small, as these things go.

Soap and web services l.jpg

SOAP and Web Services


  • Our previous lectures have looked at WSDL

    • Defines the interfaces for remote services.

    • Provides guidelines for constructing clients to the service.

    • Tells the client how to communicate with the service.

  • The actual communications are encoded with SOAP.

    • Transported by HTTP








Beyond client server l.jpg

Beyond Client-Server



  • SOAP assumes messages have an originator, one or more ultimatereceivers, and zero or more intermediaries.

  • The reason is to support distributed message processing.

  • Implementing this message routing is out of scope for SOAP.

    • Assume each node is a Tomcat server or JMS broker.

  • That is, we can go beyond client-server messaging.




Soap in one slide l.jpg

SOAP in One Slide

  • SOAP is just a message format.

    • Must transport with HTTP, TCP, etc.

  • SOAP is independent of but can be connected to WSDL.

  • SOAP provides rules for processing the message as it passes through multiple steps.

  • SOAP payloads

    • SOAP carries arbitrary XML payloads as a body.

    • SOAP headers contain any additional information

    • These are encoded using optional conventions

Defining soap messages l.jpg

Defining SOAP Messages

  • Given what you have learned about WSDL, imagine it is your job to design the message interchange layer.

    • What are the requirements?

  • Note SOAP actually predates WSDL, so this is in reverse order.

Web service messaging infrastructure requirements l.jpg

Web Service Messaging Infrastructure Requirements?

  • Define a message format

    • Define a messaging XML schema

    • Allow the message to contain arbitrary XML from other schemas.

  • Keep It Simple and Extensible

    • Messages may require advanced features like security, reliability, conversational state, etc.

    • KISS, so don’t design these but do design a place where this sort of advanced information can go.

      • Add these capabilities in further specifications: WS-Security, WS-ReliableMessaging, etc.

  • Tell the message originator is something goes wrong.

  • Define data encodings

    • That is, you need to tell the message recipient the types of each piece of data.

  • Define some RPC conventions that match WSDL

    • Your service will need to process the message, so you need to provide some simple conventions for matching the message content to the WSDL service.

  • Decide how to transport the message.

    • Generalize it, since messages may pass through many entities.

  • Decide what to do about non-XML payloads (movies, images, arbitrary documents).

Soap messaging l.jpg

SOAP Messaging

Soap basics l.jpg

SOAP Basics

  • SOAP is often thought of as a protocol extension for doing Remote Procedure Calls (RPC) over HTTP.

    • This is how it is often used.

  • This is not accurate: SOAP is an XML message format for exchanging structured, typed data.

    • It may be used for RPC in client-server applications

    • May be used to send XML documents

    • Also suitable for messaging systems (like JMS) that follow one-to-many (or publish-subscribe) models.

  • SOAP is not a transport protocol. You must attach your message to a transport mechanism like HTTP.

What does soap look like l.jpg

What Does SOAP Look Like?

  • The next two slides shows examples of SOAP message from our Echo service.

    • It’s just XML

  • First slide is an example message that might be sent from a client to the echo service.

  • Second slide is an example response.

  • I have highlighted the actual message payload.

Soap request l.jpg

SOAP Request

<?xml version=‘1.0’ ?>






<ns1:echo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"


<in0 xsi:type="xsd:string">Hollow World</in0>




Soap response l.jpg

SOAP Response

<?xml version=‘1.0’ ?>









<echoReturn xsi:type=“String“>

Hollow World





Soap structure l.jpg

SOAP Structure


  • SOAP structure is very simple.

    • 0 or 1 header elements

    • 1 body element

    • Envelop that wraps it all.

  • Body contains XML payload.

  • Headers are structured the same way.

    • Can contain additional payloads of “metadata”

    • Security information, quality of service, etc.





Soap schema notes l.jpg

All of this is expressed formally in the SOAP schema.

Which in turn derives from the SOAP Infoset

XML on the right is taken directly from the SOAP schema.

This just encodes the previously stated rules.

Also, note that the SOAP envelope can contain other attributes.

<anyAttribute> tag is the wildcard

<xs:complexType name="Envelope">


<xs:element ref="tns:Header" minOccurs="0" />

<xs:element ref="tns:Body" minOccurs="1" />


<xs:anyAttribute namespace="##other" processContents="lax" />


SOAP Schema Notes

Soap envelop l.jpg

SOAP Envelop

  • The envelop is the root container of the SOAP message.

  • Things to put in the envelop:

    • Namespaces you will need.

      • http://schemas.xmlsoap.org/soap/envelope is required, so that the recipient knows it has gotten a SOAP message.

      • Others as necessary

    • Encoding rules (optional)

      • Specific rules for deserializing the encoded SOAP data.

      • More later on this.

  • Header and body elements.

    • Headers are optional, body is mandatory.

    • Headers come first in the message, but we will look at the body first.

Options on xsd any l.jpg

Options on <xsd:any/>

  • The <xsd:any/> element takes the usual optional maxOccurs, minOccurs attributes.

  • Allows a namespace attribute taking one of the values:

    • ##any (the default),

    • ##other (any namespace except the target namespace),

    • List of namespace names, optionally including either ##targetNamespace or ##local.

      Controls what elements the wildcard matches, according to namespace.

  • It also allows a processContents attribute taking one of the values strict, skip, lax (default strict), controlling the extent to which the contents of the matched element are validated.

    • SOAP is lax.

Slide95 l.jpg


  • “If the item, or any items among its children if it's an element information item, has a uniquely determined declaration available, it must be ·valid· with respect to that definition.”

  • That is, ·validate· message payloads when you can, don't worry when you can't.

Soap headers l.jpg

SOAP Headers

  • SOAP Body elements contain the primary message contents.

  • Headers are really just extension points where you can include elements from other namespaces.

    • i.e., headers can contain arbitrary XML.

  • Headers may be processed independently of the body.

  • Headers may optionally define encodingStyle.

  • Headers may optionally have a “role” attribute

  • Header entries may optionally have a “mustUnderstand” attribute.

    • mustUnderstand=1 means the message recipient must process the header element.

    • If mustUnderstand=0 or is missing, the header element is optional.

  • Headers may also have a “relay” attribute.

Header definition from soap schema l.jpg

Header Definition From SOAP Schema

<xs:element name="Header" type="tns:Header" />

<xs:complexType name="Header">


<xs:documentation>Elements replacing the wildcard MUST be namespace qualified, but can be in the targetNamespace</xs:documentation>



<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded" />


<xs:anyAttribute namespace="##other" processContents="lax" />


Example uses of headers l.jpg

Example Uses of Headers

  • Security: WS-Security and SAML place additional security information (like digital signatures and public keys) in the header.

  • Quality of Service: SOAP headers can be used if we want to negotiate particular qualities of service such as reliable message delivery and transactions.

  • Session State Support: Many services require several steps and so will require maintenance of session state.

    • Equivalent to cookies in HTTP.

    • Put session identifier in the header.

Example header from soap primer l.jpg

Example Header from SOAP Primer

<?xml version='1.0' ?>

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">


<m:reservation xmlns:m=“http://my.example.com/" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">






<n:passenger xmlns:n=“…"


<n:name>Åke Jógvan Øyvind</n:name>



Explanation of header example l.jpg

Explanation of Header Example

  • In general, we can import tags into the header from name spaces outside of soap.

    • <reservation/>, <reference/>, <dataAndTime/>,<passenger/>

  • SOAP doesn’t need to worry to much about these.

    • It is the node’s job to process these things.

  • In this particular case, we may imagine an ongoing transaction for making an airline reservation.

    • Involves several steps and messages, so client must remind the server of this state information when sending a message.

    • The actual header content all comes from other namespaces.

  • The role and mustUnderstand attributes are from SOAP.

Header processing l.jpg

Header Processing

  • SOAP messages are allowed to pass through many intermediaries before reaching their destination.

    • Intermediary=some unspecified routing application.

    • Imagine SOAP messages being passed through many distinct nodes.

    • The final destination processes the body of the message.

  • Headers are allowed to be processed independently of the body.

    • May be processed by intermediaries.

  • This allows an intermediary application to determine if it can process the body, provide the required security, session, or reliability requirements, etc.

Roles understanding and relays l.jpg

Roles, Understanding, and Relays

















Header roles l.jpg

Header Roles

  • SOAP nodes may be assigned role designations.

  • SOAP headers then specify which role or roles should process.

  • Standard SOAP roles:

    • None: SOAP nodes MUST NOT act in this role.

    • Next: Each SOAP intermediary and the ultimate SOAP receiver MUST act in this role.

    • UltimateReceiver: The ultimate receiver MUST act in this role.

  • In our example, all nodes must process the header entries.

Soap body l.jpg


  • Body entries are really just placeholders for XML from some other namespace.

  • The body contains the XML message that you are transmitting.

  • It may also define encodingStyle, just as the envelop.

  • The message format is not specified by SOAP.

    • The <Body></Body> tag pairs are just a way to notify the recipient that the actual XML message is contained therein.

    • The recipient decides what to do with the message.

Soap body element definition l.jpg

SOAP Body Element Definition

<xs:element name="Body" type="tns:Body" />

<xs:complexType name="Body">


<xs:any namespace="##any"

processContents="lax" minOccurs="0“ maxOccurs="unbounded" />


<xs:anyAttribute namespace="##other" processContents="lax" />


Soap body example l.jpg

SOAP Body Example


<ns1:echo soapenv:encodingStyle=




<in0 xsi:type="xsd:string">HollowWorld</in0>



Example soap body details l.jpg

Example SOAP Body Details

  • The <Body> tag is extended to include elements defined in our Echo Service WSDL schema.

  • This particular style is called RPC.

    • Maps WSDL bindings to SOAP body elements.

    • Guidelines will be given in next lecture.

  • xsi-type is used to specify that the <in0> element takes a string value.

    • This is data encoding

    • Data encoding rules will also be examined in next lectures.

A broader view of web services l.jpg

A Broader View of Web Services

Beyond WSDL, SOAP, and the OASIS Swamp

Representational state transfer rest l.jpg

Representational State Transfer (REST)

  • The term REST was proposed by Roy Fielding

    • Dissertation is available from http://roy.gbiv.com/pubs/dissertation/top.htm

    • Fielding is the first author of the HTTP 1.1 Spec, IETF RFC 2616)

  • The primary concept of REST is statelessness (or idempotence).

    • All invocations of the same method should give identical responses.

  • Note REST does not have to transfer HTML

    • One could build other client server applications on top of this.

    • Famous example: WebDAV (actually predates Fielding’s dissertation).

    • Modern examples: Atom and RSS feeds emit XML data that can be easily parsed and used in applications.

    • Commonly used in mash-ups. See Yahoo’s Pipes examples.

    • That is, RSS and Atom XML don’t have to be immediately rendered for presentations.

Slide110 l.jpg

<?xml version='1.0' encoding='UTF-8'?>'

<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'>



<title type='text'>Marlon Pierce's Community Grids Lab Blog</title>

<link rel='alternate' type='text/html' href='http://communitygrids.blogspot.com/index.html'></link>

<link rel='next' type='application/atom+xml' href='http://communitygrids.blogspot.com/feeds/posts/default?start-index=26&amp;max-results=25'></link>

<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://communitygrids.blogspot.com/feeds/posts/default'></link>

<link rel='self' type='application/atom+xml' href='http://communitygrids.blogspot.com/feeds/posts/default'></link>

<author><name>Marlon Pierce</name></author>

<generator version='7.00' uri='http://www2.blogger.com'>Blogger</generator>





<title type='text'>db4o Java Bean Database</title>

<content type='html'>The db4o &lt;a href="http://www.db4o.com/"&gt;http://www.db4o.com/&lt;/a&gt; project makes a very simple,

light-weight object database. It's free, too. Maybe too free, as they use GPL. But see comment below. Obviously this sort

of thing is great if you do a lot of POJO development (say, with JSF) and need some persistent storage.&lt;br /&gt;&lt;br /&gt;The downloadable

documentation is pretty good, as is this article:

Atom and rss services l.jpg

Atom and RSS Services?

  • Sure, why not? You can convey a lot of information in a news feed.

  • Good for sequential science data

    • Seismic events

    • Recently docked drug-like molecules in on-going simulations.

  • Also it is easy to build HTTP GET query interfaces.

  • Useful for conveying metadata about projects

    • http://www.chembiogrid.org/wsrss/wsdlrss/getFeedlists available Web services, which are frequently updated.

  • Useful tools:

    • Atomsphere Java libraries

    • SimplePie RSS libraries for PHP

Rest vs soap l.jpg


  • Actually, I think it is really REST versus WSDL.

  • REST applies the same API to all applications:


    • These operations are applied to URLs

    • The actual URLs can point to XML files.

      • XML could be SOAP, ATOM, RSS, ...

    • Clients and services may do additional processing of the transmitted XML that is not in the API’s scope.

  • WSDL and XML-RPC define custom APIs specific to the application.

Realistic rest l.jpg

Realistic REST

  • From my experience, REST’s stateless philosophy is generally a good idea, even if you design and build SOAP+WSDL Web Services.

  • Some useful principals:

    • Make each service completely self-contained. The WSDL should define everything you need to invoke the service.

    • Use URLs as return values. This is especially useful for scientific services that use input and output files.

      • It’s much easier and more maintainable to use URLs to transfer files that your service needs or generates.

    • Don’t use stateful communication protocols. Park state information in a URL or in a WS-Context service.

Slide114 l.jpg

This is a portal client to a data mining service that I built. The web service analyzes GPS signal data to look for modes.

The service returns output result files as URLs.

GPS data comes from the Scripps GRWS Web Service. Instead of defining a data type for this file, we just pass around URLs. The RDAHMM service receives the URL as input.

The lesson: don’t go overboard with XML message definitions. You will regret it. Use URLs and keep your SOAP/WSDL simple.

Portal courtesy of NASA REASoN project.

Apache s3 rest l.jpg

Apache S3 REST

  • Amazon’s Simple Storage Service (S3) provides a simple for-fee online storage service.

  • Files are uploaded and downloaded using HTTP PUT and GET operations.

  • Shared symmetric session keys are used to generate unique, un-guessable URLs for files that can be reproduced by the client without having to contact the service.

  • It is all amazingly simple.

  • See docs at

    • http://docs.amazonwebservices.com/AmazonS3/

  • See my notes at

    • http://communitygrids.blogspot.com/2007/02/notes-on-amazon-s3-file-services.html

  • Login