Unit-2 Wssoa
Unit-2 Wssoa
The basic principles behind the Web services architecture are based on
SOA and the Internet protocols. It represents a composable application
solution based on standards and standards-based technologies. This ensures
that the implementations of Web services applications are compliant to
standard specifications, thus enabling interoperability with those compliant
applications.
Characteristics of web services:
The Web services architecture represents the logical evolution of
traditional computer-based applications to services-oriented applications
over the Internet. It defines a distributed computing mechanism by adopting
a service-oriented architecture (SOA), where all of the applications are
encapsulated as services and made available for invocation over a network.
These services can be leveraged from different applications and platforms
with varying technologies adopting common industry standards and
platform-independent and language neutral Internet protocols for enabling
application interoperability, thus making them easily accessible over the
Internet.
Core Building blocks of Web services:
Some of the key design requirements of the Web services architecture are the following:
Listing 3.1 represents a SOAP message using an HTTP post request for
sending a getBookPrice() method with <bookname> as an argument to
obtain a price of a book.
Listing 3.1 SOAP message using
POST /StockQuote HTTP/1.1
Host: www.acmeretailer.com
SOAPAction: “getBookPrice”
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=”http://www.w3c.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3c.org/2001/XMLSchema”
SOAP-ENV:encodingStyle
=”http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Body>
<m:getBookPrice
xmlns:m=”http://www.wiley.com/jws.book.priceList”>
<bookname xsi:type=’xsd:string’>
</m:getBookPrice>
/SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<?xml version=”1.0”?>
<definitions name=”BookPrice”
targetNamespace=”http://www.wiley.com/bookprice.wsdl”
xmlns:tns=”http://www.wiley.com/bookprice.wsdl”
<message name=”GetBookPriceInput”>
</message>
<message name=”GetBookPriceOutput”>
</message>
<portType name=”BookPricePortType”>
<operation name=”GetBookPrice”>
<input message=”tns:GetBookPriceInput”/>
<output message=”tns:GetBookPriceOutput”/>
</operation>
</portType>
<binding name=”BookPriceSoapBinding”
type=”tns:BookPricePortType”>
<soap:binding style=”rpc”
transport=”http://schemas.xmlsoap.org/soap/http”/>
<operation name=”GetBookPrice”>
<soap:operation
soapAction=”http://www.wiley.com/GetBookPrice”/>
<input>
<soap:body use=”encoded”
namespace=”http://www.wiley.com/bookprice”
encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”/>
</input>
<output>
<soap:body use=”encoded”
namespace=”http://www.wiley.com/bookprice”
encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”/>
</output>
</operation>>
</binding>
<service name=”WileyBookPriceService”>
Listing 3.2 A WSDL document describing a Service. (continued)
ebXML
ebXML provides a standard framework for building an electronic
market- place by enabling the standardization of business processes,
business part- ner profiles, and partner agreements. In general, ebXML
complements other Web services standards like SOAP, WSDL, and UDDI.
The following are major features of ebXML:
REQUEST
RESPONSE
MESSAGE
enterprise architects and developers. In addition to the Java platform, today the
J2EE-based
application environment also has become the preferred solution for running Web
servicesbased solutions.
The following steps are commonly involved in creating Web services from a
J2EE-based application component:
a. Select the potential J2EE components (for example, EJBs, Servlets, and JMS
applications) that are required to be exposed as services or are using the existing
services.
c. Ensure that the service uses only built-in/custom data types mapping for XML
and Java supported by the Web services container. This applies only to RPC-based
communication models.
3. Develop the Web service by writing the interfaces required for accessing the
exposed components (for example, EJBs, Servlets, and JMS applications).
a. Develop the potential J2EE component (for example, EJBs, Servlets, and JMS
b. Also it is important to note, the upcoming release of the J2EE 1.4 specification
is expected to provide a complete J2EE-based Web services platform and would
enable the deployment
5. Deploy the Web service components in the Web services container and make
them available to its remote clients (based on the required protocol bindings such
as HTTP and SMTP).
7. Register and publish your Web service in a UDDI registry, in case you require
enabling the service available by searching public/private UDDI registries for Web
services.
Web Services for the developer community as the Java Web Services Developer
Pack
services using the Java APIs. In addition, leading Web services platform providers
like
Systinet, CapeClear, and Mind Electric and leading J2EE vendors like BEA, IBM,
and Sun
iPlanet also released their Web services capabilities, adopting a Java platform and
supporting
JWSDP 1.0 provides a one-stop Java API solution for building Web
services using a Java platform. The key API components include the following:
Leading J2EE application server vendors have announced their support to this
effort and also started releasing their JWSDP API implementation. This helps the
developers to build Web services by exposing their existing J2EE applications.
2. WSDL-based service descriptions are generated and then reside in the services
3. Using registry APIs, WSDLs are used for publishing the services in a
public/private
UDDI registry.
1. The service requestor clients create SOAP-based client interfaces using the
WSDLbased descriptions exposed by the service provider.
2. The service requestor may choose to use any language for implementing the
client
3. These client interfaces then are used to invoke the service provider deployed
services
In Figure 5.1, all of the communication over the wire takes place on
SOAP. The following list explains the steps depicted in Figure 5.1:
■■ Step 4 finally shows the service user invoking the Web service
based on the service invocation information it extracted from the
Web service WSDL definition. This is when the service user’s
application would make use of the Java interface representing
WSDL as a proxy, in order to invoke the methods/functions
exposed by the Web service.
<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 version=”1.0”?>
<definitions name=”WeatherInfo”
targetNamespace=”http://myweather.com/weatherinfo.
wsdl”
xmlns:tns=”http://myweather.com/weatherinfo.wsdl”
xmlns:xsd1=”http://myweather.com/weatherinfo.xsd”
xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/”
xmlns=”http://schemas.xmlsoap.org/wsdl/”>
<types>
<schema targetNamespace=
“http://myweather.com/weatherinfo.xsd”
xmlns=
“http://www.w3.org/2000/10/XMLSchema”
>
<element name=”WeatherInfoRequest”>
<complexType>
<all>
<element name=”Country”
type=”string”/>
<element
name=”Zip”
type=”string”/>
<element name=”Instant”
type=”string”/>
</all>
</complexType>
</element>
<element name=”WeatherInfo”>
<complexType>
<all>
<element
name=”FTemp”
type=”float”/>
<element name=”Humidity”
type=”float”/>
</all>
</complexType>
</element>
</schema>
</types>
<message name=”GetWeatherInfoInput”>
<part
name=”WeatherInfoRequestSpec”
element=”xsd1:WeatherInfoReque
st”/>
</message>
<message name=”GetWeatherInfoOutput”>
<part name=”WeatherInfo”
<binding
name=”WeatherInfoSoapBinding”
type=”tns:WeatherInfoPortType”>
<soap:binding style=”document”
transport=”http://schemas.xmlsoap.org/soap/http”
/>
<operation name=”GetWeatherInfo”>
<soap:operation soapAction=
“http://myweather.com/GetWeatherInf
o”/>
<input>
<soap:body use=”literal”/>
</input>
<output>
<soap:body use=”literal”/>
</output>
</operation>
</binding>
<service name=”WeatherInfoService”>
<documentation>
Provides Weather Information
</documentation>
<port name=”WeatherInfoPort”
binding=”tns:WeatherInfoSoapBindi
ng”>
<soap:address location=
“http://myweather.com/provideweatherinf
o”/>
</port>
</service>
</definitions>
SOAP Binding
WSDL 1.1 defines a binding for SOAP 1.1 endpoints. This
binding provides the following SOAP protocol specific
information:
■■ An indication that the binding is bound to the SOAP 1.1 protocol
■■ A way of specifying an address for a SOAP endpoint
■■ The URI for the SOAP action HTTP header for the HTTP
binding of SOAP
■■ A list of definitions of headers that are transmitted as
part of the SOAP envelope
WSDL Tools
Systinet WASP provides two tools for working with WSDL: Java2WSDL
and WSDL Compiler. Both of these tools accomplish two different types
of functionalities related to WSDL:
Generating WSDL from a Java class that is a potential candidate for
a Web service. This functionality is taken care of by the Java2WSDL
tool.
Generating Java code from an existing WSDL. This functionality
is taken care of by the WSDL Compiler.
We will check out both these tools in the following two sections.
package jws.ch5;
}
public void SetWeatherInfo (String sCountry, String
sZip, String sInstance, String sTemperature)
{
// Update the backend weather databases
// with this information
}
}
The following command line instruction shows the usage of the
Java2WSDL tool such that it would generate a WeatherInfo.wsdl from the
WeatherInfoJavaService class:
<wsdl:definitions name=’jws.ch5.WeatherInfoJavaService’
targetNamespace=’http://www.myweather.com/WeatherInfo’
xmlns:wsdl=’http://schemas.xmlsoap.org/wsdl/’
xmlns:tns=’http://www.myweather.com/WeatherInfo’
xmlns:ns0=’http://systinet.com/xsd/SchemaTypes/’
xmlns:soap=’http://schemas.xmlsoap.org/wsdl/soap/’
xmlns:map=’http://systinet.com/mapping/’>
<?xml version=’1.0’?>
<wsdl:definitions name=’jws.ch5.WeatherInfoJavaService’
targetNamespace=’http://www.myweather.com/WeatherInfo’
xmlns:wsdl=’http://schemas.xmlsoap.org/wsdl/’
xmlns:tns=’http://www.myweather.com/WeatherInfo’
xmlns:ns0=’http://systinet.com/xsd/SchemaTypes/’
xmlns:soap=’http://schemas.xmlsoap.org/wsdl/soap/’
xmlns:map=’http://systinet.com/mapping/’>
<wsdl:types>
<xsd:schema elementFormDefault=”qualified” targetNamespace=
“http://systinet.com/xsd/SchemaTypes/”
xmlns:tns=”http://systinet.com/xsd/SchemaTypes/”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<wsdl:definitions name=’jws.ch5.WeatherInfoJavaService’
targetNamespace=’http://www.myweather.com/WeatherInfo’
xmlns:wsdl=’http://schemas.xmlsoap.org/wsdl/’
xmlns:tns=’http://www.myweather.com/WeatherInfo’
xmlns:ns0=’http://systinet.com/xsd/SchemaTypes/’
xmlns:soap=’http://schemas.xmlsoap.org/wsdl/soap/’
xmlns:map=’http://systinet.com/mapping/’>
The Java2WSDL tool supports many more arguments than what are
shown in Table 5.2.
The output WeatherInfo.wsdl generated by the Java2WSDL tool is
shown in Listing 5.2.
<xsd:element
name=”sTemperature”
nillable=”true”
type=”xsd:string”/>
</xsd:schema>
</wsdl:types>
<wsdl:message name=
‘WeatherInfoJavaService_GetWeatherInfo_1_Request’>
<wsdl:message name=’WeatherInfoJavaService_SetWeatherInfo_Response’/>
<wsdl:message name=
‘WeatherInfoJavaService_SetWeatherInfo_1_Request’>
</wsdl:message>
<wsdl:portType name=’WeatherInfoJavaService’>
<wsdl:operation name=’GetWeatherInfo’ parameterOrder=’sCountry
sZip sInstance’>
<wsdl:input message=‘tns:WeatherInfoJavaService_GetWeatherInfo_1_Request’/>
</wsdl:operation>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name=’WeatherInfoJavaService’
type=’tns:WeatherInfoJavaService’>
<wsdl:operation name=’GetWeatherInfo’>
<map:java-operation name= ‘GetWeatherInfo’ signature=’KExq...’/>
<wsdl:input>
<soap:body use=’literal’ namespace=’http://www.myweather.com/
WeatherInfoWeatherInfoJavaService’/>
</wsdl:input>
<wsdl:output>
<soap:body use=’literal’ namespace= ‘http://www.myweather.com/
WeatherInfoWeatherInfoJavaService’/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name=’SetWeatherInfo’>
<map:java-operation name=’SetWeatherInfo’ signature=’KExq...’/>
<wsdl:input>
</wsdl:input>
<wsdl:output>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name=’JavaService’>
<wsdl:port name=’WeatherInfoJavaService’
binding=’tns:WeatherInfoJavaService’>
<soap:address location=
‘urn:unknown-location-uri’/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
/**
*/
/**
*/
/**
*/
/*
This tool also has various options that enable fine-tuning of the genera- tion of the Java interface. Also,
WSDLCompiler supports the generation of Java Bean components from WSDL definitions.
The following lists some of the important enhancements of WSDL 1.2
over WSDL 1.1:
■■ WSDL 1.2 provides support for W3C Recommendations,
including XML Schemas and XML Information Set.
■■ WSDL 1.2 removes non-interoperable features from WSDL 1.1.
■■ WSDL 1.2 clearly defines HTTP 1.1 binding.
Limitations of WSDL
WSDL 1.1 has an obvious limitation: its incapability of being able to
describe complex business Web services, which typically are constituted
by orchestrating multiple finer-grained Web services. This drawback is
due to the lack of support for workflow descriptions in WSDL. To
overcome these limitations of WSDL, standards such as ebXML
Collaborative Protocol Profile/Collaborative Protocol Agreement
(CCP/A), Business Process Specification Schema (BPSS), and Web
Services Choreography Interface (WSCI) can be leveraged. An EbXML
set of technologies can be used to build business Web services.