Web Services
Web Services
Find Register
Services Services
Travel Rental Car
Services Reservation
Desktop
Registry System
Invoke
Services Hotel
PDA Service Travel Reservation
Requestor Reservation
Services System
Provider
Organization
Credit Card
Payment System..
Flgure 2.1 An example scenario of Web services.
Serice
Broker
D i s c oSveer
r v i c e
Registr Servic
Service Service
Requestor ProDder
Invoke Service
Figure 2.3 Web services operational model, shoing roles and relationships.
UDDI
Registry
POST
ntLenthiN60
APENVEnveloPe
:SOAP BNVA HESt 9/aoap
SIhttp/wwwWw3
mngXBd
g/2001/XShema
ht tp:wwwweoru0017schema Histang
SOpENVencodingstyle
thtepsche soap orsnoapeençod
NVAHead
amlnsoersoi Heade
Spersonimal.
SOAP Heade
ENBGa
book
evelopngava Web (hookname
Tu:Get:pookP1d.
SOAP ENV: Body
SOAPENSEHvelope
L0sting 4.1 SOAP request mnessage.
HTTP response
Tisting 4.2 shows the SOAP message embedded in an
returning the price of the book.
textamlcharsetekut
K640:
SOAPDNV Envelope
Cmlhs:SOAPENVEhttpLIschemas mlsoap org/9pap/ernvelope/
anlns Xs1HttBrwww.sciota200MSchenSA
KSdhttp:/www.w3aorg2001/XMLSCheima
encodingsty leEttpIs hemasn soap org7soaplencoding
SOARENV: Header
eyi sangaction
m L1eyhttp:/13 ley com/2002/bookts
ENAley:TrànsaeiOn
OAP BNVHeader
SSOAP EN Bodyn
mGetbookPridceResporise.anIhs n
PWW.NTeycÖnl5ws book
PCess0:00Price
m GeBOoKPriceResponse
ISOAPENVABOdy
SOAPENVG EAve lopes
In Listing 4.2, you might have noticed that the SOAP message contains a
SOAP Envelope SOAP-ENV :Envelope as its primary root element, and
it relies on defined "XML Namespaces" commonly identified with a
keyword xmlns and specific prefixes to identify the elements and
itsencoding rules. All the elements in the message are associated with
gOAP-ENV-defined namespaces.
Note that a SOAP application should incorporate and use the relevant
SOAP narnespaces for defining its elements and attributes of its sending
nessages; likewise, it must be able to process the receiving messages with
thoss specified namespaces. These namespaces must be in a quaified W3C
XML Schema, which facilitates the SOAP message with groupingS of
elernents using prefixes to avoid name collisions.
Usually a SOAP message requires defining two basicnamespaces: SOAP
Envelope and SOAP Encoding. The following list their forms in both
versions 1.1 and 1.2 of SOAP.
SOAP ENVELOPE
SOAP. Body
Attachment
Body entry
Attachment
Body entry
Attachment
Attachment
SOAP Envelope
The SOAP envelope is the primary container of aSOAP message's structure
and is the mandatory element of a SOAP message. It is represented as the
root element of the message as Envelope. As we discussed earlier, it is
usually declared as an element using the XML namespace htp://schemas
xmlsoap.org/soap/envelope/. As per SOAP 1.1 specifications, SOAP
messages that do not follow this namespace declaration are not processed
and are considered to be invalid. Encoding styles also canbe defined using
a namespace under Envelope to represent the data types used in the
message. Listing 4.3 shows the SOAPenvelopeelement ina SOAP message.
sOAP Header
The SOAP header is represented as the first immediate child element of a
SOAP envelope, and it has to be namespace qualified. In addition, it also
may contain zeroor more optional child elements, which are referred to as
SOAP header entries. The SOAP encodingStyle attribute will be used to
define the encoding of the data types used in header element entries. The
SOAP actor attribute and SOAP mustUnderstand attribute can be used
to indicate the target SOAP application node (Sender/Receiver/Interme
diary)and to process the Header entries. Listing4.4 shows the sample rep
resentation of a SOAP header element in a SOAP message.
SOAP Body
A SOAP envelope contains a SOAP body as its child element, and it may
contain one or more optional SQAP body block entries. The Body repre
sents the mandatory processing information or the paykoad intended for
the receiver of the message. The SOAP 1.1 specification mandates that
there must be one or more optional SOAP Boy entries in a message. A
Body block of aSOAP message can contain any of the following:
RPC method and its parameters
- Target application (receiver) specific dat
SOAP fault for reporting errors and statusinformation
SOAP Attachments
As per SOAP 1.1 with the attachment specification, a SOAP message con
tains the primary SOAPenvelope in an XML format and SOAP attachments
iñ any data fornat that can be ASCIl or binary (such as XML or non-text).
SOAP attachments are not part of the SOAP envelope but are related to the
message.
As the SOAP message is consiructed using a MIME multipart/related
structure, the SOAP attachment part of the message is contained to a
MIME boundary (defined in the Context-Type header). Each MIME part in
the structure of the SOAP message is referenced using either Content-ID or
Content-Location as labels for the part. Both the SOAP header and body of
the SOAP message also can refer to these labels in the message. Each
attachment ofthe message is identified with a Content-ID (typically an
href atiibute using a URL scheme) or Content-Location (a URI reference
assoçiate to the attachment)}
SOAP Request
SOAP Respouse
- <<-
Generated by JAX-WS RI at http://jax-ws.dev.java.net. R>'s version is Metro/2.1.1-b09
(branches/2.1-6834: 2011-07-16T17: 14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2.
-->
-<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity
utility-1.0.xsd" xml1ns:wsp="http://www.w3.org/ns/ws-policy"
xmins:wspl_2="http:/lschemas.xmlsoap.org/ws/2004/09/policy"
xmins: wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:soap="http://schemas.xnalsoap.org/wsdV'soap/" xmins:tns="http:/addition/"
Xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schenas.xmlsoap.org/wsdV" targetNamespace="http://addition/"
name="ws1">
<types>
-<xsd:schema>
<xsd:import namespace="http://addition/"
schemaLocation="http://localhost:8080/web/ws1?xsd=1">
</xsd:schema>
types>
:<message name="add">
<part name="parameters" element='tns:add" >
</message>
<message name="addResponse">
<part name-"parameters" element-"tns:addResponse" />
</message>
<message name"hello'>
<part name="parameters" element-"tns:hello" >
<message>
=<message name-"helloResponse">
<part name-"parameters" element-"tns:helloResponse" >
</message>
:portIype name-"ws1">
-<operation name-"add">
<input wsam:Action="http://addition/wsl/addRequest" message-"tns:add">
<output wsam: Action="http:/addition'wsl/addResponse" message="tns:addResponse" />
</operation>
-<operation namne-"hello>
<input wsam:Action="http://addition/ws1/helloRequest" message="tns:hello" >
<output wsam:Action="http://addition/ws1/helloResponse" message="tns:heloResponse" />
</operation>
</portType>
<binding name="ws1 PortBinding" type="tns:ws1">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style=-"document" >
:<operation name="add">
<soap:operation soapAction="">
<input>
<soap:body use="literal" />
</input>
:<output>
<soap:body use="literal" />
<Joutput>
</operation>
:<operation name="hello">
<soap:operation soapAction=">
:<input>
<soap:body use-"literal" /
</input>
:<output>
<soap:body use-"literal" >
<output>
<loperation>
<binding>
-<service namne="ws1">
-<port name-"ws1 Port" binding=-"tns: ws1 PortBinding">
<soap:address location="http:/localhost:8080/web/ws1" >
</port>
</service
<definitions>
< efinitions>. A WSDL document is a set of definitions. These
definitions aredefined inside the <definitions> element, which is the
root element in a WSDL document. It defines the name of the Web
service and also declares the namespaces that are used throughout
the rest of the WSDL document.
<types>, This element defines all of the data types that would be
used to describe the messages that are exchanged between the Web
service and the service user. WSDL does not mandate the use of a
specific typing system. However, as per the WSDL specification,
XML Schema is the default typing system.
XML Schema was discussed in Chapter 4, "Developing Web Services
Using SOAP" in the context of SOAP encoding.
<mASsage>. This element represents a logical definition of the data
being transmitted between the Web service and the service user. This
element describes a one-way message, which may represent a
contains zero
request or response sent toor from the Web service. It to the
basically refer
or more message <part> elements, which
request parameters or response return values.
<portType>. This element defines the abstract definition of the oper
ations supported by a Web service, by combining various request and
operation
response messages defined by <message> elements. Each
refers to an input message and an output message.
<binding>. This element specifies a concrete protocol and data for
mat used for representing the operations and messages defined by a
particular <portType>, on the wire.
<port>. Thiselement specifies an address for binding to the Web
service.
<service>. This element aggregates a set of related <port> ele
of the
ments, each which uniquely specify the binding informationelements
Web service, A <service> consisting of mutiple <port> over
invoked
essentially represernts the capabiity of the service to be is discussed
mutiple bindings. More information on WSDL bindings
in the next section.
WEB SERVICE:
ADD WEBSERVICE.JAVA:
package ADD2;
import javax.jws. WebMethod:
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class add {
@WebMethod(operationName = "operation")
public Integer operation(@WebParam(name = "a")
int a, (@WebParam(name = "b")
int b) {
I/TODO writeyour implementation code here:
return (atb);
ADDSERVJ.JSP:
<%@page contentType-"text/html" pageEncoding-"UTF-8"%>
<!DOCTYPEHTML PUBLIC "-//W3C//DTD HTML 4,01 TransitionaV/EN"
"http://www.w3.orgTR/html4/loose.dtd">
<htm>
<head
<meta http-cquiv-"Content-Type" content="text/html; charset-UTF-8">
title>JSP Page</title>
<head>
<form id="adderform">
firstnumber:<input type="text"'name="no 1"/>
secondnumber:<input type="text"name-"no2">
<input type="submit"value="add"/>
<form>
<body>
<h2> <h2>
o start web service invocation --%><hr>
%
try {
add webservice.ADDWebServiceService service = new
add webservice.ADDWebServiceService();
add webservice.ADDWebService port service.getADDWebServicePort);
I/TODO initialize WS operation arguments here
int a = Integer.parselnt(request.getParameter("no 1");
int b = Integer.parselnt(request.getParameter("no2"):
I/TODO process result here
java. lang.Integer result = port.add(a, b);
out.printin("Result= "tresult):
}catch (Exception ex) {
TODO handle custom exceptions here
%>
o- end web service invocation --9%><hr>
<body>
<(htm>
CwsiWeb Service Tester -Windows Internet Explorer
ocahost:tTpste .
Favortes SASted es
* Page Safety + Tooks -
wsiWeb Service Tester
(WSDL Fie)
This fora wÌaos you to test your web service implementaion
boxes and cick on the button labeied with the method name.
Io oke an operation, fi the method parameter(s) input
Methods :
Explo. MX
Ahethod invDcatíon traceWindows internet
Fe
Hew Favortes Tools Help
add AMethodinvocation
Method parzmeter(s)
Type Vane
int
Methodretuned
nt:8*
firstmumber4 secondnumber4
add
Hello World!
Resuit =8
.UDDI Registries
An implementation of the UDDIspecification is termed as a UDDIregistry.
UDDI registry services are a set of software services that provide access to
the UDDI registry. Meanwhile, registry services can perform a plethora of
other activities such as authenticating and authorizing registry requests,
logging registry requests, load-balancing requests, and so on.
SytWAUTD1,4TRWRERU
nd brhem
Brtrot
-al ers
rcedleece qrvehe
gnal
Iedes
brad aane matd: C Yes
am CMesere: Gyes
ert y . BUnsartadAec CDemendng
Dore Unrtad DAKenKdne
PND
UDDISpecifications
All versions of the UDDIspecifications can be obtained from the UDDI
organization at their Web site at http://uddi.org/specification.html. The
UDDI 2.0 specification set includes the following documents:
UDDI replication. The document describes the data replication
process. of the UDDIregistries. Also, it describes the programmatic
interfaces supported by UDDIfor achieving replication between
UDDI registries operated by different operators.
UDDIoperators. This document provides information on the opera
tional behavior that should be followed by UDDI node operators. For
example, the document defines guidelines that node operators can
folow in order to manage the data of the UDDI registry node. Such
guidelines inchude the following:
Node operators' responsibiity for durable recording and backup
of all data.