Professional Documents
Culture Documents
Web Services are published, found, and used through the Web.
Before you continue, you should have a basic understanding of the following:
HTML
XML
If you want to study these subjects first, find the tutorials on our Home page.
XML provides a language which can be used between different platforms and
programming languages and still express complex messages and functions.
SOAP
4. SOAP enables client applications to easily connect to remote services and invoke
remote methods.
5. Other frameworks, including CORBA, DCOM, and Java RMI, provide similar
functionality to SOAP, but SOAP messages are written entirely in XML and are
therefore uniquely platform- and language-independent.
SOAP Message Structure
Envelope: ( Mandatory )
Defines the start and the end of the message.
Header: ( Optional )
Contains any optional attributes of the message used in processing the message,
either at an intermediary point or at the ultimate end point.
Body: ( Mandatory )
Contains the XML data comprising the message being sent.
Fault: ( Optional )
An optional Fault element that provides information about errors that occurred
while processing the message
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2001/12/soap-envelope"
SOAP-ENV:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<SOAP-ENV:Header>
...
...
</SOAP-ENV:Header>
<SOAP-ENV:Body>
...
...
<SOAP-ENV:Fault>
...
...
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP_ENV:Envelope>
The SOAP envelope indicates the start and the end of the message so that the receiver
knows when an entire message has been received. The SOAP envelope solves the
problem of knowing when you're done receiving a message and are ready to process it.
The SOAP envelope is therefore basic ally a packaging mechanism
<?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:Body>
<m:GetPrice
<m:Quotation>This is Qutation</m:Quotation>
After <m:GetPrice>
xmlns:m="http://www.w3schools.com/prices">
<m:Item>Apples</m:Item>
SOAP Header Element
The optional</m:GetPrice>
Header element offers a flexible framework for specifying additional
</soap:Body>
application-level requirements. For example, the Header element can be used to specify
a digital signature for password-protected services; likewise, it can be used to specify
</soap:Envelope>
an account number for pay-per-use SOAP services.
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.
The example above requests the quotation of computer sets. Note that the m:GetPrice
and the Item elements above are application-specific elements. They are not a part of
the SOAP standard.
<?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>
The Price service might be implemented using an EJB running in an application server;
</m:GetPriceResponse>
if so, the SOAP processor would be responsible for mapping the body information as
</soap:Body>
parameters into and out of the EJB implementation of the GetPriceResponse service.
The SOAP processor could also be mapping the body information to a .NET object, a
</soap:Envelope>
CORBA object, a COBOL program, and so on.
WSDL
Web Services Description Language is the standard format for describing a web service
in XML format.
WSDL is very easy to learn and very important for Web Services.
WSDL Abstract:
WSDL stands for Web Services Description Language
WSDL is an XML based protocol for information exchange in decentralized and
distributed environments.
WSDL is the standard format for describing a web service.
WSDL definition describes how to access a web service and what operations it
will perform.
WSDL is a language for describing how to interface with XML-based services.
WSDL is an integral part of UDDI, an XML-based worldwide business registry.
WSDL is the language that UDDI uses.
WSDL was developed jointly by Microsoft and IBM.
WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'
WSDL Usage:
WSDL is often used in combination with SOAP and XML Schema to provide web services
over the Internet. A client program connecting to a web service can read the WSDL to
determine what functions are available on the server. Any special datatypes used are
embedded in the WSDL file in the form of XML Schema. The client can then use SOAP
to actually call one of the functions listed in the WSDL.
Data types: the data types - in the form of XML schemas or possibly some
other mechanism - to be used in the messages
Port type : an abstract set of operations mapped to one or more end points,
defining the collection of operations for a binding; the collection of operations,
because it is abstract, can be mapped to multiple transports through various
bindings.
Binding: the concrete protocol and data formats for the operations and
messages defined for a particular port type.
In addition to these major elements, the WSDL specification also defines the following
utility elements:
NOTE: WSDL parts usually are generated automatically using Web services-aware
tools.
Analysis of the Example
Definition : DefinitionsName
Type : Using built-in data types and they are defined in XMLSchema.
Message :
1. getSummary : firstName parameter
2. getSummaryResponse: greeting return value
Data types address the problem of how to identify the data types and format you intend
to use with your Web services. Type information is shared between sender and
receiver. The recipients of messages therefore need access to the information you used
to encode your data and must understand how to decode the data.
Here, two message elements are defined. The first represents a request message
getSummary, and the second represents a response message
getSummaryResponse.
Each of these messages contains a single part element. For the request, the part
specifies the function parameters; in this case, we specify a single zipcode parameter.
For the response, the part specifies the function return values; in this case, we specify a
single return return value.
WSDL portType Element
The <portType> element combines multiple message elements to form a complete
oneway or round-trip operation.
For example, a <portType> can combine one request and one response message into a
single request/response operation. This is most commonly used in SOAP services. A
portType can define multiple operations.
Patterns of Operation
One-way :
The service receives a message. The operation therefore has a single input element. The grammar
for a one-way operation is:
<wsdl:definitions .... > <wsdl:portType .... > *
<wsdl:operation name="nmtoken">
<wsdl:input name="nmtoken"? message="qname"/>
</wsdl:operation>
</wsdl:portType >
</wsdl:definitions>
Request-response:
The service receives a message and sends a response. The operation therefore has one input
element, followed by one output element. To encapsulate errors, an optional fault element can
also be specified. The grammar for a request-response operation is:
<wsdl:definitions .... >
<wsdl:portType .... > *
<wsdl:operation name="nmtoken" parameterOrder="nmtokens">
<wsdl:input name="nmtoken"? message="qname"/>
<wsdl:output name="nmtoken"? message="qname"/>
<wsdl:fault name="nmtoken" message="qname"/>*
</wsdl:operation>
</wsdl:portType >
</wsdl:definitions>
Solicit-response:
The service sends a message and receives a response. The operation therefore has one output
element, followed by one input element. To encapsulate errors, an optional fault element can also
be specified. The grammar for a solicit-response operation is:
<wsdl:definitions .... >
<wsdl:portType .... > *
<wsdl:operation name="nmtoken" parameterOrder="nmtokens">
<wsdl:output name="nmtoken"? message="qname"/>
<wsdl:input name="nmtoken"? message="qname"/>
<wsdl:fault name="nmtoken" message="qname"/>*
</wsdl:operation>
</wsdl:portType >
</wsdl:definitions>
Notification :
The service sends a message. The operation therefore has a single output element. Following is
the grammer for a notification operation:
<wsdl:definitions .... >
<wsdl:portType .... > *
<wsdl:operation name="nmtoken">
<wsdl:output name="nmtoken"? message="qname"/>
</wsdl:operation>
</wsdl:portType >
</wsdl:definitions>
<binding type=“dictionaryWords"
name="b1">
<soap:binding style="document“
transport=
"http://schemas.xmlsoap.org/soap/ht
tp" />
<operation>
<soap:operation
soapAction="http://example.com/getT
SOAP Binding
erm"/>
WSDL 1.1 includes built-in extensions for SOAP 1.1. This enables you to specify
SOAPspecific details,<input> <soap:body
including SOAP headers, SOAP encoding styles, and the
SOAPAction HTTP header. The SOAP extension elements include:
use="literal"/> </input>
soap:binding <output> <soap:body
This element use="literal"/> </output>
indicates that the binding will be made available via SOAP. The style
</operation>
attribute indicates the overall style of the SOAP message format. A style value of rpc
specifies an RPC format.
</binding>
The transport attribute indicates the transport of the SOAP messages. The value
http://schemas.xmlsoap.org/soap/http indicates the SOAP HTTP transport, whereas
http://schemas.xmlsoap.org/soap/smtp indicates the SOAP SMTP transport.
soap:operation
This element indicates the binding of a specific operation to a specific SOAP
implementation. The soapAction attribute specifies that the SOAPAction HTTP header
be used for identifying the service.
soap:body
This element enables you to specify the details of the input and output messages. In
the case of HelloWorld, the body element specifies the SOAP encoding style and the
namespace URN associated with the specified service.
The port element has two attributes - the name attribute and the binding
attribute.
The name attribute provides a unique name among all ports defined within in the
enclosing WSDL document.
The binding attribute refers to the binding using the linking rules defined by
WSDL.
Binding extensibility elements (1) are used to specify the address information for
the port.
A port MUST NOT specify more than one address.
A port MUST NOT specify any binding information other than address
information.
The binding attributes of port element associate the address of the service with a
binding element defined in the Web service
UDDI
UDDI is an XML-based standard for describing, publishing, and finding Web services.
A set of WSDL port type definitions for manipulating and searching that registry
o describing services,
UDDI roles
• Service Registry
• Service Provider
• Service Requestor
Consider a company XYZ wants to register its contact information, service description,
and online service access information with UDDI. The following steps are necessary:
1. Choose an operator with which to work. Each operator has different terms and
conditions for authorizing access to its replica of the registry.
2. Build or otherwise obtain a UDDI client, such as those provided by the operators.
6. Use the inquiry APIs to test the retrieval of the information, including binding
template information, to ensure that someone who obtains it can use it
successfully to interact with your service.
7. Fill in the tModel information in case someone wants to search for a given
service and find your business as one of the service providers.
The following examples how the XYZ Company would register its information and how a
distributor interested in carrying the XYZ's product line might find information about
how to contact the company and place an order, using the XYZ.com Web services.
Creating Registry:
Retrieving Information:
After XYZ Company has updated its UDDI entry with the relevant information,
companies that want to become XYZ distributors can look up contact information in the
UDDI registry and obtain the service descriptions and the access points for the two Web
services that XYZ.com publishes for online order entry: preseason bulk orders and in-
season restocking orders.
• JAXP
• JAX-RPC
– Sends SOAP method calls to remote parties over the internet and receives
the results
• JAXM
Simplified in JavaEE