Web Service Introduction
Web service is the strongest era of 20th century to develop multi language multi platform enterprise application.Nowadays every IT industry is bound to use web services to enhance their business in a sophisticated manner so that they can enhance their business with so many partner.Web services is not a technology which has been launched by a vender rather it is a group of multiple standard and specification provided by multiple vendor to developed a web based distributed application which can run in architectural neutral and language independent manner.
Service Oriented Architecture
Service-oriented architecture (SOA) is an evolution of distributed computing based on the request/reply design paradigm for synchronous and asynchronous applications. An application's business logic or individual functions are modularized and presented as services for consumer/client applications. The key to these services is their loosely coupled nature; i.e., the service interface is independent of the implementation. Application developers or system integrators can build applications by composing one or more services without knowing the services' underlying implementations.For example, a service can be implemented either in .Net or J2EE, and the application consuming the service can be on a different platform or language.
Web services is based on Service Oriented Architecture(SOA) which is a plan rather than implementation to develop a web based distributed application..
Every SOA based application will have following characteristics....
- SOA services have self-describing interfaces in platform-independent XML documents. Web Services Description Language (WSDL) is the standard used to describe the services.
- SOA services communicate with messages formally defined via XML Schema (also called XSD). Communication among consumers and providers or services typically happens in heterogeneous environments, with little or no knowledge about the provider. Messages between services can be viewed as key business documents processed in an enterprise.
- SOA services are maintained in the enterprise by a registry that acts as a directory listing. Applications can look up the services in the registry and invoke the service. Universal Description, Definition, and Integration (UDDI) is the standard used for service registry.
- Each SOA service has a quality of service (QoS) associated with it. Some of the key QoS elements are security requirements, such as authentication and authorization, reliable messaging, and policies regarding who can invoke services
Specification of Web Services..
XML Specification
XML (extensible Markup Language)
XML Namespaces
XML Schema
XPath
XQuery
XML Information Set
XInclude
XML Pointer
Messaging Specification
SOAP (formerly known as Simple Object Access Protocol)
SOAP-over-UDP[3]
SOAP Message Transmission Optimization Mechanism
WS-Notification
WS-BaseNotification
WS-Topics
WS-BrokeredNotification
WS-Addressing
WS-Transfer
WS-Eventing
WS-Enumeration
WS-MakeConnection
Metadata Exchange Specification
JSON-WSP
WS-Policy
WS-PolicyAssertions
WE-PolicyAttachment
WS-Discovery
WS-Inspection
WS-MetadataExchange
Universal Description Discovery and Integration (UDDI)
WSDL 2.0 Core
WSDL 2.0 SOAP Binding
Web Services Semantics (WSDL-S)
WS-Resource Framework (WSRF)
Security Specification
WS-Security
XML Signature
XML Encryption
XML Key Management (XKMS)
WS-SecureConversation
WS-SecurityPolicy
WS-Trust
WS-Federation
WS-Federation Active Requestor Profile
WS-Federation Passive Requestor Profile
Web Services Security Kerberos Binding
Web Single Sign-On Interoperability Profile
Web Single Sign-On Metadata Exchange Protocol
Security Assertion Markup Language (SAML)
XACML
The web service standard are mentioned below.
- IBM developerWork: Standard and Web Service
- innoQ's WS-Standard
- MSDN .NET Developer Centre: Web Service Specification Index Page
- OASIS Standards and Other Approved Work
- Open Grid Forum Final Document
- XML CoverPage
- W3C's Web Services Activity
In industry developer works to develop service based application using above specification.
The most commonly usable standard are..
- Wsdl(Web service description language)
- Soap(Simple object access protocol)
- Ws-Security(Web service Security)
Web service description language
It is a language which is platform independent ,architecture neutral which is the heart to develop a web service application.
- WSDL is written in XML
- WSDL is an XML document
- WSDL is used to describe Web services
- WSDL is also used to locate Web services
- WSDL is a W3C recommendation
A WSDL file contains following element to specify the service in xml language.
element Name
|
Description
|
types
|
A container for abstract
type definitions defined using XML Schema
|
message
|
A definition of an abstract
message that may consist of multiple parts, each part may be of a different
type
|
port Type
|
An abstract set of
operations supported by one or more endpoints (commonly known as an
interface); operations are defined by an exchange of messages
|
binding
|
A concrete protocol and data
format specification for a particular portType
|
service
|
A collection of related
endpoints, where an endpoint is defined as a combination of a binding and an
address (URI)
|
A simple wsdl file is mentioned below...
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:y="http://example.org/math/" xmlns:ns="http://example.org/math/types/" targetNamespace="http://example.org/math/"> <types> <xs:schema targetNamespace="http://example.org/math/types/" xmlns="http://example.org/math/types/" elementFormDefault="unqualified" attributeFormDefault="unqualified"> <xs:complexType name="MathInput"> <xs:sequence> <xs:element name="x" type="xs:double"/> <xs:element name="y" type="xs:double"/> </xs:sequence> </xs:complexType> <xs:complexType name="MathOutput"> <xs:sequence> <xs:element name="result" type="xs:double"/> </xs:sequence> </xs:complexType> <xs:element name="Add" type="MathInput"/> <xs:element name="AddResponse" type="MathOutput"/> <xs:element name="Subtract" type="MathInput"/> <xs:element name="SubtractResponse" type="MathOutput"/> <xs:element name="Multiply" type="MathInput"/> <xs:element name="MultiplyResponse" type="MathOutput"/> <xs:element name="Divide" type="MathInput"/> <xs:element name="DivideResponse" type="MathOutput"/> </xs:schema> </types> <message name="AddMessage"> <part name="parameters" element="ns:Add"/> </message> <message name="AddResponseMessage"> <part name="parameters" element="ns:AddResponse"/> </message> <message name="SubtractMessage"> <part name="parameters" element="ns:Subtract"/> </message> <message name="SubtractResponseMessage"> <part name="parameters" element="ns:SubtractResponse"/> </message> <message name="MultiplyMessage"> <part name="parameters" element="ns:Multiply"/> </message> <message name="MultiplyResponseMessage"> <part name="parameters" element="ns:MultiplyResponse"/> </message> <message name="DivideMessage"> <part name="parameters" element="ns:Divide"/> </message> <message name="DivideResponseMessage"> <part name="parameters" element="ns:DivideResponse"/> </message> <portType name="MathInterface"> <operation name="Add"> <input message="y:AddMessage"/> <output message="y:AddResponseMessage"/> </operation> <operation name="Subtract"> <input message="y:SubtractMessage"/> <output message="y:SubtractResponseMessage"/> </operation> <operation name="Multiply"> <input message="y:MultiplyMessage"/> <output message="y:MultiplyResponseMessage"/> </operation> <operation name="Divide"> <input message="y:DivideMessage"/> <output message="y:DivideResponseMessage"/> </operation> </portType> <binding name="MathSoapHttpBinding" type="y:MathInterface"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="Add"> <soap:operation soapAction="http://example.org/math/#Add"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> <operation name="Subtract"> <soap:operation soapAction="http://example.org/math/#Subtract"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> <operation name="Multiply"> <soap:operation soapAction="http://example.org/math/#Multiply"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> <operation name="Divide"> <soap:operation soapAction="http://example.org/math/#Divide"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <service name="MathService"> <port name="MathEndpoint" binding="y:MathSoapHttpBinding"> <soap:address location="http://localhost/math/math.asmx"/> </port> </service> </definitions>
A wsdl is a mediator to talk with different technology and language.In otherwords it provides
abstraction on technology dependant language and uses a common language called xml to expose
the service to the service client.
Simple Object Access Protocol
Soap is protocol which runs over Http protocol and is called "soap over http" interms of webservice.
It is a application level protocol which depends upon HTTP to send the data over the data. It uses xml language to transfer the data over the network.
In simply a soap protocol...
- SOAP stands for Simple Object Access Protocol
- SOAP is a communication protocol
- SOAP is for communication between applications
- SOAP is a format for sending messages
- SOAP communicates via Internet
- SOAP is platform independent
- SOAP is language independent
- SOAP is based on XML
- SOAP is simple and extensible
- SOAP allows you to get around firewalls
<?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>
<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>
A simple soap message contains two parts.
- Soap Header
- Soap Body
- Soap Fault
Soap Header
SOAP Header element can be explained as:- Header elements are optional part of SOAP messages.
- Header elements can occur multiple times.
- Headers are intended to add new features and functionality
- The SOAP header contains header entries defined in a namespace.
- The header is encoded as the first immediate child element of the SOAP envelope.
- When more than one header is defined, all immediate child elements of the SOAP header are interpreted as SOAP header blocks.
The most important part of soap header is ,it contains security information.
SOAP Header is optional and the element contains application-specific information (like authentication, payment, etc) about the SOAP message.
If the Header element is present, it must be the first child element of the Envelope element.
- Actor attribute:
The SOAP protocol defines a message path as a list of SOAP service nodes. Each of these intermediate nodes can perform some processing and then forward the message to the next node in the chain. By setting the Actor attribute, the client can specify the recipient of the SOAP header.
- MustUnderstand attribute
Indicates whether a Header element is optional or mandatory. If set to true ie. 1 the recipient must understand and process the Header attribute according to its defined semantics, or return a fault.
A typical soap header structure is like...
<?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>
<m:Trans xmlns:m="http://www.w3schools.com/transaction/"
soap:mustUnderstand="1">234
</m:Trans>
</soap:Header>
...
...
</soap:Envelope>
Soap Body
SOAP Body is the required element contains the actual SOAP message intended for the ultimate endpoint of the message.
A soap body contains the actual data which is supposed to be send across the network through the http request
soap body is the immediate child elements of the SOAP Body element may be namespace-qualified.
A typical soap body message contains two parts.
- Soap Request
- Soap Response
Soap Response contain the response data which contains the information.In otherwords it is called processed data
.
A typical soap body with request data is looks like below....
<?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:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>
</soap:Envelope>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>
</soap:Envelope>
And the response body contains..
<?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:Body>
<m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
Here Apple is the item which has to send to the webservice to get the price and is called request made by webservice client and 1.90 is the response to the webservice client on behalf of the request.
No comments:
Post a Comment