Saturday, February 27, 2010

Web Services

Web Services are a self defined services which can be two way request and response or can be one way.A web service can be registered in a UDDI Universal description,discover and Integration Registry so that other applications can locate it.
IT can be called asynchronously or synchronously.It can interact with other software packages using XML based messages and internet based protocols.If mathematically web services has to be defined then i will say

web services = XML + HTTP

i.e. you can say web service is composed of a message protocol (XML) and a transport protocol (HTTP)

Web services standards

SOAP Simple Object Access Protocol
===================================

SOAP is a simple XML based protocol which allows the applications to exchange information over the HTTP.In relation to web-services we can call it as a protocol for accessing a web-service.The best feature of SOAP is that it is protocol independent,language independent,Platform and operating system independent.


A SOAP has following building blocks

1>Envelope.
2>Soap Header.
3>Soap Body.
4>Fault handler.

Ok lets understand this

When we post a letter to some one we have wrap it in the envelope then have to provide the address where we want to post it.Envelope is in the same way an element that indentifies the XML document as a SOAP Message.

The general syntax for a SOAP message is

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>
...
</soap:Header>

<soap:Body>
...
<soap:Fault>
...
</soap:Fault>
</soap:Body>

</soap:Envelope>

As you can see it must include the root element envelope and within the envelope we have to mention the header ,body and then fault.The namespace that we have defined must contain the value "http://www.w3.org/2001/12/soap-envelope".

The SOAP header contains the application specific information about the SOAP message.


WSIL Web Service Inspection Language.(WS-Inspection)
=======================================

WSIL is an XML format that helps in assisting inspection of a site for available services and a set of rules for how inspection related information should be retrieved for consumption.It provides a means for collecting references to pre-existing service description documents which are published in any number of formats.

Web Service Interoperability(WS-I)
===================================

It is an organization that helps web services to be operable across platform, application and programming languages.

WSDL Web Service Description Language
======================================
It is an XML based language for describing web services and how to access them.
A WSDL document contains the following elements.

1>Type-Data type used by the web service.
2>Messages-Messages used by the web service.
3>PortType-Operation performed by web service.
4>Binding-Communication protocol used by web service.

So a WSDL document should essentially look like this

<definitions>

<types>
.......
</types>

<message>
....
</message>

<portType>
.......
</portType>

<binding>
....
</binding>

</definitions>

Port element is very important as it defines the operational capability of the web services.Operation can be one or two-way.

Binding element

The binding element has two attributes - name and type.

The name attribute defines the name of the binding, and the type attribute points to the port for the binding.

The soap:binding element has two attributes - style and transport.

The style attribute can be "rpc" or "document". In this case we use document. The transport attribute defines the SOAP protocol to use.

<binding type="callArpit" name="Arpit">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
........................
</binding>

Here Arpit is the name of binding and callArpit is the operation which should be defined in port element.

No comments: