WS
WS
Topics
WSDL
describes
Web Service
WSDL
is accessed using
Enables discovery of
UDDI
WSDL definition
<types>
….
</types>
abstract
definition
<message>
…
</message>
<portType> or <interface>
….
</portType> or </interface>
concrete
definition
<binding>
….
</binding>
<service>
…
</service>
Concrete: Specific location and implementation information about a Web service are the
concrete parts of a WSDL document, as represented by the binding, service, and
endpoint (or port) elements.
Eg:
<definitions>
<interface or portType name="Catalog">
<operation name="GetBook">
…
</operation>
</interface or portType >
</definitions>
Eg:
<definitions>
….
<message name="BookInfo">
…
</message>
<interface or portType name="Catalog">
<operation name="GetBook">
<input name="Msg1" message="BookInfo" />
</operation>
..
</definitions>
25 Web Services 05/14/2025
WSDL- message
A message element can contain one or more input or output parameters that belong to
an operation.
Each part element defines one such parameter. It provides a name/ value set, along with
an associated data type.
In a component-based architecture, a WSDL part is the equivalent of an input or output
parameter (or a return value) of a component method.
Eg:
<definitions>
<message name="BookInfo">
<part name="title* type>
Field Guide
</part>
<part name="author* type="xs:string">
Mr. Teshale
</part>
</message>
</definition
26 Web Services 05/14/2025
WSDL-Abstract
Here’s a brief summary of the fundamental constructs that can be assembled to establish
abstract interface definition:
* operations represent a Web service function, and can reference multiple messages
* messages represent collections of input or output parameters, and can contain multiple parts
<env:Header>
…
</env:Header>
<env: Body>
…
</env: Body>
</env:Envelope>
<env:Envelope xmlns;env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<n:shipping >
UPS
</n:shipping>
</env:Header>
<env:Body>
…
</env:Body>
</env:Envelope>
<?xml version="1.0"?>
<soap: Envelope
xmlns:soap="http://mm.w3.org/20@1/12/soap-envelope”
soap:encodingStyle="http://www.w3. org/2001/12/soap-encoding">
<s:GetStockPrice>
<s:StockName>Oracle</s:StockName>
</s:GetStockPrice>
</soap:Body>
</soap:Envelope>
<?xml _version="1.0”?>
<soap:Envelope
xmlns : soap="http://www.w3.0rg/2001/12/soap-envelope”
soap:encodingStyle="http: //m.w3.org/2001/12/soap-encoding”>
<soap:Body xmlns:s="http://www.Stock_brokerage.org/stock">
<s:GetStockPriceResponse>
<s:Price>100.50</s:Price>
</s:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>
The SOAP request message is posted to the HTTP server with the HTTP
request, and the server returns the SOAP response message in the
HTTP response
<s:Envelope xmlns:s="http://www.w3.org/2001/06/soap-envelope">
...
</s:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml
Content-Length: nnnn
<s:Envelope xmlns:s="http://www.w3.org/2001/06/soap-envelope">
...
</s:Envelope>
Contract first approach using WSDL( Top down approach/ Reverse engineering)
It is a useful approach in case of generating web service implementation from the
contract/WSDL/interface doc.
Using annotations:
Annotate class/interface as @Webservice
Eg:
@Webservice
class FinnancialService{
}
Annotating web service operations
@Webservice
class FinnancialService{
@Webmethod
public List<Amount> convertToUSD( ArrayList<AmountInFC> a);
}
import javax.xml.ws.Endpoint;
public class Ep {
public static void main(String args[]){
Endpoint.publish("http://localhost:12345/cal", new Cal());
}
}
wsimport is used to generate stubs of the web service using its WSDL
Document
Eg:
wsimport options
http://ravindras-macbook-air-10.local:8080/WS51/Cal?wsdl
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Cal_Service cs= new Cal_Service();
System.out.println(cs.getCalPort().add(40, 400));
System.out.println(cs.getCalPort().hello("Babu"));
}
}
49 Web Services 05/14/2025
Web Services Implementation
uses uses
UDDI
is accessed using
Describes the service for
SOAP
enables discovery of
binds to uses
BPEL4WS for
xt
o nte str
at es
uses
esc c h e
Provides proto n ag or WSDL
col for Ma E
tra nabl
ns e d
ac is
WS-Coordination tio tri enables communication between
n s bu
f o t ed
r
describes
t
tex
Provides proto co n Provides guaranteed delivery for
col for es
a nag
M
f or Web Services
WS-Transaction
of
bi es
Pr
l i a ov
en ovi
y
li t
re pr
d de
se s e
Im
cu n s
ri t d -t
y govern WS-Reliable
fo o -
r
messaging
WS-Security WS-Policy
es
es
us
us
57 Web Services 05/14/2025
REST Services