Based on the request and the response Web Services can be classified into
Synchronous and Asynchronous.
In Synchronous services the client invokes the Web Service and waits
for the response from the server. Hence this is used when the server
responds immediately and there is no time delay to process the request.
Mostly RPC style Web Services are synchronous in nature.
The following diagram shows a synchronous stock quote service. The
client sends the stock symbol in the request and the server responds with
the quote details.
In Asynchronous services the client invokes the Web Service but does not
wait for the response from the server. Generally document oriented Web
Services use Asynchronous, where the server receives the document does some
processing and sends back the response to the client. The implementation of
asynchronous may vary from vendor to vendor. Some approaches are
The following example shows a asynchronous loan processing service using
WS-Conversation. The client sends a XML Document to the server by calling the
initiate method and gets an acknowledgement ID. The server process the loan
document and sends the response to the CallBack port of the client. If
required the client can poll the server using the acknowledgement ID.
More...Transport
The transport is the layer that carries SOAP messages. In this section
we shall look at HTTP, Message and SMTP transport for carrying SOAP
messages.
HTTP Transport
HTTP is the most common form of binding for SOAP messages. The
request message is sent over http from the client to server. The
response message from the server also travels over http to the client.
For HTTP transport the binding is set to http://schemas.xmlsoap.org/soap/http
in the WSDL.
The following shows sample SOAP request and response messages with
HTTP headers
POST /DOMService/services/DOMService HTTP/1.0Content-Type: text/xml;
charset=utf-8Accept: application/soap+xml, application/dime,
multipart/related, text/*User-Agent: Axis/1.0Host: localhostCache-Control:
no-cachePragma: no-cacheSOAPAction: ""Content-Length: 309
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<Test>
<Ones>1</Ones>
<Two>three</Two>
</Test>
</soapenv:Body>
</soapenv:Envelope>
HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Date: Fri, 07 Mar
2003 04:22:54 GMTServer: Apache Coyote/1.0Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<Test>
<Ones>1</Ones>
<Two>three</Two>
</Test>
</soapenv:Body>
</soapenv:Envelope>
JMS/MQ Transport:
JMS/MQ provides MOM based channel for carrying messages. MOM products
offer asynchronous delivery, guaranteed delivery, once only delivery,
persistent messages that can be used for Web Services. The following shows
Web Service implementation using JMS server.
In the above framework the Web Service gives the price for the part
requested and the SOAP message is transported using a JMS server like
Weblogic or SonicMQ.
The SOAP Client constructs the message that contains the part ID for
which the price is required. It invokes the AXIS Client that checks the
transport. Since the transport is for JMS the JMSSender gets the message
and puts it in the request Queue. The JMSListener receives the message and
creates an instance of AXIS Server that invokes the corresponding web
service. The web service gives the response that is got by the AXIS
Server. This is placed in the response Queue and the JMS Sender gets the
response that is passed to the SOAP client.
SMTP Transport:
SMTP is very widely used like HTTP and can also be used for carrying SOAP
messages. Some of the advantages are its widespread use, asynchronous, store
and forward. Hence one way messaging and two way using correlation of the
request and response are possible using SMTP for SOAP. For SMTP the binding is
set to http://schemas.pocketsoap.com/soap/smtp
in the WSDL.
To: <soap@example.org>
From: <soap@client.com>
Reply-To: <soap@client.com>
Date: Tue, 15 Nov 2001 23:27:00 -0700
Message-Id: <1F75D4D515C3EC3F34FEAB51237675B5@client.com>
MIME-Version: 1.0
Content-Type: text/xml; charset=utf-8
Content-Transfer-Encoding: QUOTED-PRINTABLE
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=3D"http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC=3D"http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV=3D"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<m:echoString xmlns:m=3D"http://soapinterop.org/">
<inputString>get your SOAP over SMTP here !</inputString>
</m:echoString>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
To: <soap@client.com>
From: <soap@example.org>
Date: Tue, 13 Nov 2001 23:27:00 -0700
In-Reply-To: <1F75D4D515C3EC3F34FEAB51237675B5@client.com>
Message-Id: <FF75D4D515C3EC3F34FEAB51237675B5@soap.example.org>
MIME-Version: 1.0
Content-Type: TEXT/XML; charset=utf-8
Content-Transfer-Encoding: QUOTED-PRINTABLE
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=3D"http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC=3D"http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV=3D"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<m:echoStringResponse xmlns:m=3D"http://soapinterop.org/">
<return>get your SOAP over SMTP here !</return>
</m:echoStringResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SMTP
This is similar to JMS Transport except that there is a SMTP Handler for
sending mails and a SMTP listener to get the mails at the server end. The following diagram shows framework for using SMTP transport for SOAP
messages.
POP
For POP the receiver polls the server to get all the incoming mails and
processes the requests by calling the Web Service.
References
Reference Path
SOAP http://www.w3.org/TR/SOAP/
WSDL http://www.w3.org/TR/wsdl
UDDI http://www.uddi.org/
AXIS http://ws.apache.org/axis/index.html
WS-Conversation http://dev2dev.bea.com/technologies/webservices/SOAPConversation.jsp
SMTP Binding for SOAP http://www.pocketsoap.com/specs/smtpbinding/
SMTP/SOAP http://www7b.boulder.ibm.com/wsdd/library/techarticles/0212_hygh/hygh.html
JMS/SOAP http://www-106.ibm.com/developerworks/webservices/library/ws-jms/index.html?dwzone=webservices
Abbreviations
Abbreviation Explanation/ Expansion of the abbreviation
SOAP Simple Object Access Protocol
UDDI Universal Description Discovery and Integration
WSDL Web Services Description Language
RPC Remote Procedure Call
JMS Java Messaging Service
MQ IBM MQSeries
HTTP Hyper Text Transmission Protocol
SMTP Simple Mail Transfer Protocol
POP Post Office Protocol
Appendix
Axis Web Services
Axis has four styles of Web Services that can be deployed. These are
- RPC
- Document
- Wrapped
- Message
RPC: RPC services follow the SOAP RPC and encoding rules. Axis will
serialize the XML in SOAP to Java Objects and also deserialize the Java
objects to XML.
Document/Wrapped: The Document/Wrapped services are similar and both used XML Schema
rather than SOAP encoding for the data. Axis uses Java binding for the XML
data.
The following sample contains a SOAP message with a purchase order
<soap:Envelope xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<soap:Body>
<myNS:PurchaseOrder xmlns:myNS="http://commerce.com/PO">
<item>SK001</item>
<quantity>1</quantity>
<description>Sushi Knife</description>
</myNS:PurchaseOrder>
</soap:Body>
</soap:Envelope>
The schema for this purchase order
<schema targetNamespace="http://commerce.com/PO">
<complexType name="POType">
<sequence>
<element name="item" type="xsd:string"/>
<element name="quantity" type="xsd:int"/>
<element name="description" type="xsd:string"/>
</sequence>
</complexType>
<element name="PurchaseOrder" type="POType"/>
</deployment>
For a document style web service the PurchaseOrder is sent as an object
from the client.
This would be <method>(PurchaseOrder po).
For a wrapped style service the <PurchaseOrder> Element is just a
wrapper for the item,quantity and description. The method would be
<method>(String item,int quantity,String description)
Message: Message style services are used when we want to send XML DOM without turning
into Java objects. Hence the sent and received messages are treated as XML DOM
objects rather than Java Objects.
About the Author
Krishnakumar B : Consultant Mindtree Consulting – Bangalore INDIA
Email : b_krishnakumar@mindtree.com
I am a Consultant with Mindtree Consulting based in Bangalore India. I work
on Web Services and J2EE related technologies and am currently involved with
trying to build applications using Web Services.