SlideShare a Scribd company logo
1 of 33
Java
Web Services
Kumar Gaurav
k10gaurav@gmail.com
Agenda
1. Overview
2. Architecture
3. WSDL
4. SOAP
5. UDDI
6. An Example
Overview
General Definition
“Web services are software components that interact with one another
dynamically via standard Internet Technologies, making it possible to build
bridges between IT systems that otherwise would require extensive
development efforts”
-Gartner Group
Web services are
Complementary to existing technology
Building blocks (components) used to construct larger applications
Evolutionary technology: The latest in a long line of approaches for distributed
applications communication
Web services are NOT
A rip and replace technology
A solution to all the integration woes
Overview
Key Features
 Web services are self-contained.
On the client side, no additional software is required. A programming
language with XML and HTTP client support is enough to get you started.
On the server side, merely a Web server and a SOAP server are required.
 Web services are self-describing.
Neither the client nor the server knows or cares about anything besides the
format and content of request and response messages (loosely coupled
application integration).
 Web services can be published, located, and invoked across the Web.
This technology uses established lightweight Internet standards such as HTTP.
It leverages the existing infrastructure. Some additional standards that
are required to do so include SOAP, WSDL, and UDDI.
 Web services are language-independent and interoperable.
Client and server can be implemented in different environments. Existing
code does not have to be changed in order to be Web service enabled.
Cntd…
Overview
Key Features
 Web services are inherently open and standard-based.
XML and HTTP are the major technical foundation for Web services. A large part
of the Web service technology has been built using open-source projects.
Therefore, vendor independence and interoperability are realistic goals this
time.
 Web services build on proven mature technology
There are a lot of commonalities, as well as a few fundamental differences to
other distributed computing frameworks. For example, Web services are build
with SOA Architecture.
 Web services are loosely coupled
Traditionally, application design has depended on tight interconnections at both
ends. Web services require a simpler level of coordination that allows a more
flexible re-configuration for an integration of the services in question.
 Web services provide the ability to wrap existing applications
Already existing stand-alone applications can easily be integrated into the
service-oriented architecture by implementing a Web service as an interface.
Architecture
Characteristics of the Web service architecture
 Webservice that follows the service-oriented architecture employs a
loose coupling betweenthe participants. Such a loose coupling provides
greater flexibility:
 In this architecture, a client is not coupled to a server, but to a service.
Thus, the integration of the server to use takes place outside of the scope
of the client application programs.
 Functional components and their interfaces are separated. Therefore,
new interfaces can be plugged in more easily.
 Within complex applications, the control of business processes can be
isolated. A business rule engine can be incorporated to control the
workflow of a defined business process. Depending on the state of the
workflow, the engine calls the respective services.
 Bindings are specified using configuration files and can thus easily be
adapted to new needs.
Continue…
Concept of a service-oriented
 The service provider creates a Web service and possibly publishes its
interface and access information to the service registry.
 The service broker (also known as service registry) is responsible for making
the Web service interface and implementation access information
available to any potential service requestor.
 The service requestor locates entries in the broker registry using various find
operations and then binds to the service provider in order to invoke one of
its Web services.
Continue…
Core Technologies
The following are the core technologies used for Web services.
 XML (eXtensible Markup Language)
The markup language that underlies most of the specifications used for Web
services. XML is a generic language that can be used to describe any kind of
content in a structured way, separated from its presentation to a specific device.
 SOAP (Simple Object Access Protocol)
SOAP similar to JDBC, is a network, transport, and programming language and
platform neutral protocol that allows a client to call a remote service. The message
format is XML.
 WSDL (Web services description language)
WSDL is an XML-based interface and implementation description language. The
service provider uses a WSDL document in order to specify the operations a Web
service provides, as well as the parameters and data types of these operations. A
WSDL document also contains the service access information.
 UDDI (universal description, discovery, and integration)
UDDI is both a client-side API and a SOAP-based server implementation that can be
used to store and retrieve information on service providers and Web services.
WSDL
WSDL architecture
 Web Services Description Language (WSDL) files
are written in Extensible Markup Language (XML).
 WSDL is one alternative to make service
interfaces and implementations available in the
UDDI registry.
 WSDL includes the workflow description (business
process execution language for Web services,
BPEL4WS)
 WSDL is the base for SOAP server deployment
and SOAP client generation.
A WSDL file contains the following parts:
Web service interface definition
 This is part contains the elements, as
well as the namespaces.
Web service implementation
 This part contains the definition of
the service and ports.
 The following is the structure of the
information in a WSDL file : A WSDL file
contains the following parts:
WSDL Architecture
 The following is the structure of the information in a WSDL file : A WSDL file
contains the following parts:
Port Type
Messages
Types
Bindings
Service
Ports
Operation Signatures
Parameter Definitions
Complex Type Definitions
Transport protocol and payload format
Service Definition Element
Supported Interface Bindings
Continue…
A WSDL file describes a Web service with the following elements:
 portType
 The description of the operations and associated messages. The
portType element defines abstract operations.
<portType name="EightBall">
<operation name="getAnswer">
<input message="ebs:IngetAnswerRequest"/>
<output message="ebs:OutgetAnswerResponse"/>
</operation>
</portType>
 message
 The description of input and output parameters and return values.
<message name="IngetAnswerRequest">
<part name="meth1_inType" type="ebs:questionType"/>
</message>
<message name="OutgetAnswerResponse">
<part name="meth1_outType" type="ebs:answerType"/>
</message>
WSDL
 types
 The schema for describing XML types used in the messages.
<types>
<xsd:schema targetNamespace="...">
<xsd:complexType name="questionType">
<xsd:element name="question" type="string"/> </xsd:complexType>
<xsd:complexType name="answerType">
...
</types>
 binding
 The bindings describe the protocol that is used to access a portType, as well as the data formats for
the messages that are defined by a particular portType element.
<binding name="EightBallBinding" type="ebs:EightBall"> <soap:binding style="rpc”
transport="schemas.xmlsoap.org/soap/http">
<operation name="ebs:getAnswer">
<soap:operation soapAction="urn:EightBall"/>
<input>
<soap:body
namespace="urn:EightBall" ... />
…
WSDL
The services and ports define the location of the Web service
 Service
 The service contains the Web service name and a list of ports.
 Ports
 The ports contain the location of the Web service and the
binding used for service access.
<service name="EightBall">
<port binding="ebs:EightBallBinding" name="EightBallPort">
<soap:address
location="localhost:8080/axis/EightBall"/>
</port>
</service>
SOAP
SOAP
 SOAP is a lightweight protocol intended for exchanging structured information
in a decentralized, distributed environment. SOAP uses XML technologies to
define an extensible messaging framework, which provides a message
construct that can be exchanged over a variety of underlying protocols. The
framework has been designed to be independent of any particular
programming model and other implementation specific semantics.
 It represents the main way of communication between the three key actors in
a service oriented architecture (SOA): service provider, service requestor and
service broker. The main goal of its design is to be simple and extensible. A
SOAP message is used to request a Web service.
SOAP
 SOAP can be used over any transport protocol such as TCP, HTTP, SMTP
 This protocol consists of three parts:
 An envelope that defines a framework for describing message content and
processing instructions.
 A set of encoding rules for expressing instances of application-defined data types.
 A convention for representing remote procedure calls and responses.
 SOAP is a protocol-independent transport and can be used in combination with a
variety of protocols. In Web services SOAP is used in combination with HTTP, HTTP
extension framework and Java Message Service (JMS).
 SOAP is also operating-system independent and not tied to any programming
language or component technology.
 As long as the client can issue XML messages, it does not matter what technology
is used to implement the client. Also, both server and client sides can reside on any
suitable platform.
SOAP
SOAP Schema:
The Envelope element is always the root element of a SOAP
message. The Envelope element contains an optional Header
element, followed by a mandatory Body element.
The Body element represents the message payload. The Body
element is a generic container in that it can contain any number of
elements from any namespace. This is ultimately where the data
goes that you're trying to send.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<!-- optional -->
<!-- header blocks go here... -->
</soap:Header>
<soap:Body>
<!-- payload or Fault element goes here... -->
</soap:Body>
</soap:Envelope>
SOAP
 SOAP Request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<x:TransferFunds xmlns:x="urn:examples-org:banking">
<from>01-4-2006</from>
<to>31-04-2006</to>
<amount>100.00</amount>
</x:TransferFunds>
</soap:Body>
</soap:Envelope>
 SOAP Response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<x:TransferFundsResponse xmlns:x="urn:examples-org:banking">
<balances>
<account>
<id>22-342439</id>
<balance>33.45</balance>
</account>
</balances>
</x:TransferFundsResponse>
</soap:Body>
</soap:Envelope>
SOAP
 Fault Code
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Insufficient funds</faultstring> <detail>
<x:TransferError
xmlns:x="urn:examples-org:banking">
<sourceAccount>22- 342439</sourceAccount>
<transferAmount>
100.00</transferAmount>
<currentBalance>
89.23</currentBalance>
</x:TransferError>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
UDDI
 The Universal Description, Discovery and Integration (UDDI)
define a way to publish and discover information about Web
services. The term “Web service” describes specific business
functionality exposed by a company, usually through an
Internet connection, for the purpose of providing a way for
another company or software program to use the service.
 Conceptually, the information provided in a UDDI business
registration consists of three components:
 white pages
 address, contact, and known identifiers;
 yellow pages
 industrial categorizations based on standard taxonomies;
 green pages
 the technical information about services that are exposed by
the business. Green pages include references to specifications
for Web services, as well as support for pointers to various file and
URL based discovery mechanisms if required.
Service Styles
Service Styles - RPC, Document, Wrapped, and Message
 RPC:
 RPC services are the default in Axis
 Axis will deserialize XML into Java objects which can be fed to your service, and will
serialize the returned Java object(s) from your service back into XML.
 Document
 Document services do not use any encoding (so in particular, you won't see multiref
object serialization or SOAP-style arrays on the wire) but DO still do XML<->Java
databinding
 Wrapped
 Wrapped services are just like document services, except that rather than binding
the entire SOAP body into one big structure, they "unwrap" it into individual
parameters
 Message
 Message services receive and return arbitrary XML in the SOAP Envelope without
any type mapping / data binding. If you want to work with the raw XML of the
incoming and outgoing SOAP Envelopes, write a message service
D:Program Files
j2sdk_nbnetbeans3.5to
Service Styles
 <schema targetNamespace="http://commerce.com/PO">
<complexType name="POType">
<sequence>
<element name="item" type="xsd:string"/>
<element name="quantity" type="xsd:int"/>
<element name="description" type="xsd:string"/>
</sequence>
</complexType>
<element name="PurchaseOrder" type="POType"/>
 document style service, this would map to a method like this:
 public void method(PurchaseOrder po)
In other words, the ENTIRE <PurchaseOrder> element would be handed to your method as a
single bean with three fields inside it. On the other hand,
• wrapped style service, it would map to a method like this:
 public void purchaseOrder(String item, int quantity, String description)
 Message Service
public Element [] method(Element [] bodies);
public SOAPBodyElement [] method (SOAPBodyElement [] bodies);
public Document method(Document body);
public void method(SOAPEnvelope req, SOAPEnvelope resp);
Service Styles
 Standard mappings from WSDL to Java
An Example
Axis Setup
 Axis software in the form of xml-axis-beta3-bin.zip can be downloaded from
http://archive.apache.org/dist/ws/axis/beta3
 Extract the folder from zip file to c:/xml-axis folder
 Set “%XML_AXIS% = c:/xml-axis” as environment variable
 Set classpath = %XML_AXIS%libaxis.jar; %XML_AXIS% libcommons-logging.jar;
%XML_AXIS%libjaxrpc.jar;c:xml-axisliblog4j-1.2.4.jar; %XML_AXIS%libtt-
bytecode.jar; %XML_AXIS%libwsdl4j.jar;%XML_AXIS%libxmlParserAPIs.jar;
%XML_AXIS%libsaaj.jar %JAVA_HOME%libtools.jar;
Apache Tomcat Setup
 Download Apache tomcat (jakarta-tomcat-4.1.31.exe) from
http://mirror.tomato.it/apache/jakarta/tomcat-4/v4.1.31/bin
 Set “CATALINA_HOME = C:Apache Tomcat 4.0” as environment variable
 Also set “path=%path%;CATALINA_HOMEbin”
 Add the following in server.xml (C:Apache Tomcat 4.0conf).
 <Context path="/axis" docBase="C:xml-axiswebappsaxis" debug="0"/>
 Start tomacat web server
An Example
A sample java Class
public class HelloWorld{
public String sayHello(String reader){
System.out.println("Service Called");
return "Hi " + reader + " How are you";
}
}
Steps to Expose as Web Service
 Write the following to a text file and name it as HelloWorldService.wsdd.
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns=“http://xml.apache.org/axis/wsdd/” xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="HelloWorldService" provider="java:RPC">
<parameter name="allowedMethods" value=“sayHello"/>
<parameter name="className" value="HelloWorld"/>
</service>
</deployment>
An Example
 Use the above wsdl file to expose as web service with the following command.
 java -classpath "%classpath%;C:jarsaxis.jar;C:jarsjaxrpc.jar;C:jarscommons-
logging-1.0.3.jar;C:jarscommons-discovery-0.2.jar;C:jarsjndi.jar;C:jarssaaj.jar;."
org.apache.axis.client.AdminClient -h localhost -p 8080 -s
WebservicesTest/servlet/AxisServlet "C:HelloWorldService.wsdd“
 Test the exposed web service
 http://localhost:8080/WebservicesTest/servlet/AxisServlet
 Click on “wsdl” to view wsdl file in browser.
 Use the following command to generate wsdl file for the exposed service
 Java org.apache.axis.wsdl.Java2WSDL HelloWorld -l
http://localhost:8080/WebservicesTest/services/HelloWorldService
 Copy the wsdl file to %XML_AXIS% root
 Use the following command to generate the stubs for given wsdl file
 java org.apache.axis.wsdl.WSDL2Java C:xml-axisHelloWorldService.wsdl
 For the generated stubs write a java class to access the web service.
An Example
Java code to access the web service via stubs
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
public class HelloWorldStubClient {
public static void main(String[] args) {
try{
//Fetch HelloWorldService object from Service Locator generated
HelloWorldService hWorldService = new HelloWorldServiceLocator();
//Fetch actual service hosted from the service.
HelloWorld hWorld = hWorldService.getHelloWorldService();
//call the Service method
System.out.println(hWorld.sayHello("Harish"));
}catch(ServiceException sExc){
sExc.printStackTrace();
}catch(RemoteException rExc){
rExc.printStackTrace();
}
}
}
An Example
 java org.apache.axis.utils.tcpmon
Documentation
 The JAX-WS 2.0 specification demands that the exception annotated with @WebFault must
have two constructors and one method:
 WrapperException(String message, FaultBean faultInfo)
WrapperException(String message, FaultBean faultInfo, Throwable cause)
FaultBean getFaultInfo()
The WrapperException is replaced by the name of the exception, and FaultBean is replaced by
the class name that implements the fault bean. The fault bean is a Java bean that contains the
information of the fault and is used by the Web service client to know the cause for the fault.
 Sample
 @javax.xml.ws.WebFault(name="AddNumbersException",
    targetNamespace="http://server.fromjava/jaxws")
public class AddNumbersException_Exception extends Exception {
    private fromjava.client.AddNumbersException faultInfo;
    public AddNumbersException_Exception(String message, AddNumbersException faultInfo) {
        super(message);
        this.faultInfo = faultInfo;
    }
    public AddNumbersException_Exception(String message, AddNumbersException faultInfo,
                                         Throwable cause) {
        super(message, cause);
        this.faultInfo = faultInfo;
    }
    public AddNumbersException getFaultInfo() {
        return faultInfo;
    }
}
Documentation
HandlerChain
Example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<javaee:handler-chains xmlns:javaee=http://java.sun.com/xml/ns/javaee xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<javaee:handler-chain>
<javaee:handler-chain-name>Service Framework Handlers</javaee:handler-chain-name>
<javaee:handler>
<javaee:handler-name>LoggingHandler</javaee:handler-name>
<javaee:handler-class>com.test.handlers.LoggingHandler
</javaee:handler-class>
</javaee:handler>
<javaee:handler>
<javaee:handler-name>ThrottlingHandler</javaee:handler-name>
<javaee:handler-class>com.test.handlers.ThrottlingHandler
</javaee:handler-class>
</javaee:handler>
</javaee:handler-chain>
</javaee:handler-chains>
Documentation
HandlerChain
Example:
Handler Interface
public class LoggingHandler implements
SOAPHandler<SOAPMessageContext>
public boolean handleFault(SOAPMessageContext context)
public boolean handleMessage(SOAPMessageContext context)
public Set<QName> getHeaders()
Documentation
 URLs
 http://today.java.net/pub/a/today/2006/09/19/asynchronous-jax-
ws-web-services.html
 http://java.sun.com/webservices/docs/2.0/tutorial/doc/
 http://ws.apache.org/axis/java/user-guide.html#Introduction
Thank You!

More Related Content

What's hot

[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发
 

What's hot (20)

ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
 
React workshop
React workshopReact workshop
React workshop
 
Online Book Portal
Online Book PortalOnline Book Portal
Online Book Portal
 
Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface)
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Types of Drivers in JDBC
Types of Drivers in JDBCTypes of Drivers in JDBC
Types of Drivers in JDBC
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Webservices
WebservicesWebservices
Webservices
 
Cloud Service Life-cycle Management
Cloud Service Life-cycle ManagementCloud Service Life-cycle Management
Cloud Service Life-cycle Management
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
Json
JsonJson
Json
 
online blogging system
online blogging systemonline blogging system
online blogging system
 
Java &amp; advanced java
Java &amp; advanced javaJava &amp; advanced java
Java &amp; advanced java
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Jsp(java server pages)
Jsp(java server pages)Jsp(java server pages)
Jsp(java server pages)
 
Web services
Web servicesWeb services
Web services
 

Viewers also liked

LinkedIn - A Professional Network built with Java Technologies and Agile Prac...
LinkedIn - A Professional Network built with Java Technologies and Agile Prac...LinkedIn - A Professional Network built with Java Technologies and Agile Prac...
LinkedIn - A Professional Network built with Java Technologies and Agile Prac...
LinkedIn
 

Viewers also liked (12)

Web Services
Web ServicesWeb Services
Web Services
 
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
 
JavaOne 2015 CON7547 "Beyond the Coffee Cup: Leveraging Java Runtime Technolo...
JavaOne 2015 CON7547 "Beyond the Coffee Cup: Leveraging Java Runtime Technolo...JavaOne 2015 CON7547 "Beyond the Coffee Cup: Leveraging Java Runtime Technolo...
JavaOne 2015 CON7547 "Beyond the Coffee Cup: Leveraging Java Runtime Technolo...
 
JavaOne 2015 Keynote Presentation
JavaOne 2015 Keynote PresentationJavaOne 2015 Keynote Presentation
JavaOne 2015 Keynote Presentation
 
Wsdl
WsdlWsdl
Wsdl
 
WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015
 
Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)
 
Stop doing scrum; start doing agile
Stop doing scrum; start doing agileStop doing scrum; start doing agile
Stop doing scrum; start doing agile
 
Web service introduction
Web service introductionWeb service introduction
Web service introduction
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentation
 
LinkedIn - A Professional Network built with Java Technologies and Agile Prac...
LinkedIn - A Professional Network built with Java Technologies and Agile Prac...LinkedIn - A Professional Network built with Java Technologies and Agile Prac...
LinkedIn - A Professional Network built with Java Technologies and Agile Prac...
 
Presentation & communication skills
Presentation & communication skills Presentation & communication skills
Presentation & communication skills
 

Similar to Java web services

webservices overview
webservices overviewwebservices overview
webservices overview
elliando dias
 
Service Oriented Architecture Updated Luqman
Service Oriented Architecture Updated  LuqmanService Oriented Architecture Updated  Luqman
Service Oriented Architecture Updated Luqman
guesteb791b
 
Semantic Web Services (Standards, Monitoring, Testing and Security)
Semantic Web Services  (Standards, Monitoring, Testing and Security)Semantic Web Services  (Standards, Monitoring, Testing and Security)
Semantic Web Services (Standards, Monitoring, Testing and Security)
Reza Gh
 
SOA Fundamentals
SOA  FundamentalsSOA  Fundamentals
SOA Fundamentals
abhi1112
 

Similar to Java web services (20)

WebService-Java
WebService-JavaWebService-Java
WebService-Java
 
Introduction to webservices
Introduction to webservicesIntroduction to webservices
Introduction to webservices
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company india
 
webservices overview
webservices overviewwebservices overview
webservices overview
 
Unit 6 SDET Web Services Testing.pptx
Unit 6 SDET Web Services Testing.pptxUnit 6 SDET Web Services Testing.pptx
Unit 6 SDET Web Services Testing.pptx
 
Web programming
Web programmingWeb programming
Web programming
 
Unit 3-SOA Technologies
Unit 3-SOA TechnologiesUnit 3-SOA Technologies
Unit 3-SOA Technologies
 
Overview of web services
Overview of web servicesOverview of web services
Overview of web services
 
Web Programming
Web ProgrammingWeb Programming
Web Programming
 
Service Oriented Architecture Updated Luqman
Service Oriented Architecture Updated  LuqmanService Oriented Architecture Updated  Luqman
Service Oriented Architecture Updated Luqman
 
Semantic Web Services (Standards, Monitoring, Testing and Security)
Semantic Web Services  (Standards, Monitoring, Testing and Security)Semantic Web Services  (Standards, Monitoring, Testing and Security)
Semantic Web Services (Standards, Monitoring, Testing and Security)
 
Secc tutorials development and deployment of rest web services in java_v2.0
Secc tutorials development and deployment of rest web services in java_v2.0Secc tutorials development and deployment of rest web services in java_v2.0
Secc tutorials development and deployment of rest web services in java_v2.0
 
SOA & WCF
SOA & WCFSOA & WCF
SOA & WCF
 
Distributed system architecture
Distributed system architectureDistributed system architecture
Distributed system architecture
 
Service view
Service viewService view
Service view
 
Xml.ppt
Xml.pptXml.ppt
Xml.ppt
 
Web Services in Cloud Computing.pptx
Web Services in Cloud Computing.pptxWeb Services in Cloud Computing.pptx
Web Services in Cloud Computing.pptx
 
SOA Fundamentals
SOA  FundamentalsSOA  Fundamentals
SOA Fundamentals
 
Cc unit 2 updated
Cc unit 2 updatedCc unit 2 updated
Cc unit 2 updated
 
Web services concepts, protocols and development
Web services concepts, protocols and developmentWeb services concepts, protocols and development
Web services concepts, protocols and development
 

More from kumar gaurav

More from kumar gaurav (20)

Need Of Enterprise Integration
Need Of Enterprise IntegrationNeed Of Enterprise Integration
Need Of Enterprise Integration
 
Mulesoft file connector
Mulesoft file connectorMulesoft file connector
Mulesoft file connector
 
Mulesoft http connector
Mulesoft http connectorMulesoft http connector
Mulesoft http connector
 
Reason to connect with Mulesoft
Reason to connect with MulesoftReason to connect with Mulesoft
Reason to connect with Mulesoft
 
Mulesoft idempotent Message Filter
Mulesoft idempotent Message FilterMulesoft idempotent Message Filter
Mulesoft idempotent Message Filter
 
Mulesoft Using Groovy Component
Mulesoft Using Groovy ComponentMulesoft Using Groovy Component
Mulesoft Using Groovy Component
 
Mulesoft vm transport reference
Mulesoft vm transport referenceMulesoft vm transport reference
Mulesoft vm transport reference
 
Mulesoft Calling Flow of Other Applications
Mulesoft Calling Flow of Other ApplicationsMulesoft Calling Flow of Other Applications
Mulesoft Calling Flow of Other Applications
 
Mulesoft Solutions for Mobile
Mulesoft Solutions for MobileMulesoft Solutions for Mobile
Mulesoft Solutions for Mobile
 
Mulesoft Solutions for SOA
Mulesoft Solutions for SOAMulesoft Solutions for SOA
Mulesoft Solutions for SOA
 
Mulesoft Solutions for IoT
Mulesoft Solutions for IoTMulesoft Solutions for IoT
Mulesoft Solutions for IoT
 
Mulesoft Anypoint platform for APIs
Mulesoft Anypoint platform for APIsMulesoft Anypoint platform for APIs
Mulesoft Anypoint platform for APIs
 
Oracle Managed Files Transfer- Key based authentication
Oracle Managed Files Transfer- Key based authenticationOracle Managed Files Transfer- Key based authentication
Oracle Managed Files Transfer- Key based authentication
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Struggle that counts
Struggle that countsStruggle that counts
Struggle that counts
 
Team Work
Team WorkTeam Work
Team Work
 
MySQL index optimization techniques
MySQL index optimization techniquesMySQL index optimization techniques
MySQL index optimization techniques
 
Security guidelines for web development
Security guidelines for web developmentSecurity guidelines for web development
Security guidelines for web development
 
Oracle web center suit
Oracle web center suitOracle web center suit
Oracle web center suit
 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Java web services

  • 2. Agenda 1. Overview 2. Architecture 3. WSDL 4. SOAP 5. UDDI 6. An Example
  • 3. Overview General Definition “Web services are software components that interact with one another dynamically via standard Internet Technologies, making it possible to build bridges between IT systems that otherwise would require extensive development efforts” -Gartner Group Web services are Complementary to existing technology Building blocks (components) used to construct larger applications Evolutionary technology: The latest in a long line of approaches for distributed applications communication Web services are NOT A rip and replace technology A solution to all the integration woes
  • 4. Overview Key Features  Web services are self-contained. On the client side, no additional software is required. A programming language with XML and HTTP client support is enough to get you started. On the server side, merely a Web server and a SOAP server are required.  Web services are self-describing. Neither the client nor the server knows or cares about anything besides the format and content of request and response messages (loosely coupled application integration).  Web services can be published, located, and invoked across the Web. This technology uses established lightweight Internet standards such as HTTP. It leverages the existing infrastructure. Some additional standards that are required to do so include SOAP, WSDL, and UDDI.  Web services are language-independent and interoperable. Client and server can be implemented in different environments. Existing code does not have to be changed in order to be Web service enabled. Cntd…
  • 5. Overview Key Features  Web services are inherently open and standard-based. XML and HTTP are the major technical foundation for Web services. A large part of the Web service technology has been built using open-source projects. Therefore, vendor independence and interoperability are realistic goals this time.  Web services build on proven mature technology There are a lot of commonalities, as well as a few fundamental differences to other distributed computing frameworks. For example, Web services are build with SOA Architecture.  Web services are loosely coupled Traditionally, application design has depended on tight interconnections at both ends. Web services require a simpler level of coordination that allows a more flexible re-configuration for an integration of the services in question.  Web services provide the ability to wrap existing applications Already existing stand-alone applications can easily be integrated into the service-oriented architecture by implementing a Web service as an interface.
  • 6. Architecture Characteristics of the Web service architecture  Webservice that follows the service-oriented architecture employs a loose coupling betweenthe participants. Such a loose coupling provides greater flexibility:  In this architecture, a client is not coupled to a server, but to a service. Thus, the integration of the server to use takes place outside of the scope of the client application programs.  Functional components and their interfaces are separated. Therefore, new interfaces can be plugged in more easily.  Within complex applications, the control of business processes can be isolated. A business rule engine can be incorporated to control the workflow of a defined business process. Depending on the state of the workflow, the engine calls the respective services.  Bindings are specified using configuration files and can thus easily be adapted to new needs.
  • 7. Continue… Concept of a service-oriented  The service provider creates a Web service and possibly publishes its interface and access information to the service registry.  The service broker (also known as service registry) is responsible for making the Web service interface and implementation access information available to any potential service requestor.  The service requestor locates entries in the broker registry using various find operations and then binds to the service provider in order to invoke one of its Web services.
  • 9. Core Technologies The following are the core technologies used for Web services.  XML (eXtensible Markup Language) The markup language that underlies most of the specifications used for Web services. XML is a generic language that can be used to describe any kind of content in a structured way, separated from its presentation to a specific device.  SOAP (Simple Object Access Protocol) SOAP similar to JDBC, is a network, transport, and programming language and platform neutral protocol that allows a client to call a remote service. The message format is XML.  WSDL (Web services description language) WSDL is an XML-based interface and implementation description language. The service provider uses a WSDL document in order to specify the operations a Web service provides, as well as the parameters and data types of these operations. A WSDL document also contains the service access information.  UDDI (universal description, discovery, and integration) UDDI is both a client-side API and a SOAP-based server implementation that can be used to store and retrieve information on service providers and Web services.
  • 10. WSDL WSDL architecture  Web Services Description Language (WSDL) files are written in Extensible Markup Language (XML).  WSDL is one alternative to make service interfaces and implementations available in the UDDI registry.  WSDL includes the workflow description (business process execution language for Web services, BPEL4WS)  WSDL is the base for SOAP server deployment and SOAP client generation. A WSDL file contains the following parts: Web service interface definition  This is part contains the elements, as well as the namespaces. Web service implementation  This part contains the definition of the service and ports.  The following is the structure of the information in a WSDL file : A WSDL file contains the following parts:
  • 11. WSDL Architecture  The following is the structure of the information in a WSDL file : A WSDL file contains the following parts: Port Type Messages Types Bindings Service Ports Operation Signatures Parameter Definitions Complex Type Definitions Transport protocol and payload format Service Definition Element Supported Interface Bindings
  • 12. Continue… A WSDL file describes a Web service with the following elements:  portType  The description of the operations and associated messages. The portType element defines abstract operations. <portType name="EightBall"> <operation name="getAnswer"> <input message="ebs:IngetAnswerRequest"/> <output message="ebs:OutgetAnswerResponse"/> </operation> </portType>  message  The description of input and output parameters and return values. <message name="IngetAnswerRequest"> <part name="meth1_inType" type="ebs:questionType"/> </message> <message name="OutgetAnswerResponse"> <part name="meth1_outType" type="ebs:answerType"/> </message>
  • 13. WSDL  types  The schema for describing XML types used in the messages. <types> <xsd:schema targetNamespace="..."> <xsd:complexType name="questionType"> <xsd:element name="question" type="string"/> </xsd:complexType> <xsd:complexType name="answerType"> ... </types>  binding  The bindings describe the protocol that is used to access a portType, as well as the data formats for the messages that are defined by a particular portType element. <binding name="EightBallBinding" type="ebs:EightBall"> <soap:binding style="rpc” transport="schemas.xmlsoap.org/soap/http"> <operation name="ebs:getAnswer"> <soap:operation soapAction="urn:EightBall"/> <input> <soap:body namespace="urn:EightBall" ... /> …
  • 14. WSDL The services and ports define the location of the Web service  Service  The service contains the Web service name and a list of ports.  Ports  The ports contain the location of the Web service and the binding used for service access. <service name="EightBall"> <port binding="ebs:EightBallBinding" name="EightBallPort"> <soap:address location="localhost:8080/axis/EightBall"/> </port> </service>
  • 15. SOAP SOAP  SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. SOAP uses XML technologies to define an extensible messaging framework, which provides a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics.  It represents the main way of communication between the three key actors in a service oriented architecture (SOA): service provider, service requestor and service broker. The main goal of its design is to be simple and extensible. A SOAP message is used to request a Web service.
  • 16. SOAP  SOAP can be used over any transport protocol such as TCP, HTTP, SMTP  This protocol consists of three parts:  An envelope that defines a framework for describing message content and processing instructions.  A set of encoding rules for expressing instances of application-defined data types.  A convention for representing remote procedure calls and responses.  SOAP is a protocol-independent transport and can be used in combination with a variety of protocols. In Web services SOAP is used in combination with HTTP, HTTP extension framework and Java Message Service (JMS).  SOAP is also operating-system independent and not tied to any programming language or component technology.  As long as the client can issue XML messages, it does not matter what technology is used to implement the client. Also, both server and client sides can reside on any suitable platform.
  • 17. SOAP SOAP Schema: The Envelope element is always the root element of a SOAP message. The Envelope element contains an optional Header element, followed by a mandatory Body element. The Body element represents the message payload. The Body element is a generic container in that it can contain any number of elements from any namespace. This is ultimately where the data goes that you're trying to send. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <!-- optional --> <!-- header blocks go here... --> </soap:Header> <soap:Body> <!-- payload or Fault element goes here... --> </soap:Body> </soap:Envelope>
  • 18. SOAP  SOAP Request <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <x:TransferFunds xmlns:x="urn:examples-org:banking"> <from>01-4-2006</from> <to>31-04-2006</to> <amount>100.00</amount> </x:TransferFunds> </soap:Body> </soap:Envelope>  SOAP Response <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <x:TransferFundsResponse xmlns:x="urn:examples-org:banking"> <balances> <account> <id>22-342439</id> <balance>33.45</balance> </account> </balances> </x:TransferFundsResponse> </soap:Body> </soap:Envelope>
  • 19. SOAP  Fault Code <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>Insufficient funds</faultstring> <detail> <x:TransferError xmlns:x="urn:examples-org:banking"> <sourceAccount>22- 342439</sourceAccount> <transferAmount> 100.00</transferAmount> <currentBalance> 89.23</currentBalance> </x:TransferError> </detail> </soap:Fault> </soap:Body> </soap:Envelope>
  • 20. UDDI  The Universal Description, Discovery and Integration (UDDI) define a way to publish and discover information about Web services. The term “Web service” describes specific business functionality exposed by a company, usually through an Internet connection, for the purpose of providing a way for another company or software program to use the service.  Conceptually, the information provided in a UDDI business registration consists of three components:  white pages  address, contact, and known identifiers;  yellow pages  industrial categorizations based on standard taxonomies;  green pages  the technical information about services that are exposed by the business. Green pages include references to specifications for Web services, as well as support for pointers to various file and URL based discovery mechanisms if required.
  • 21. Service Styles Service Styles - RPC, Document, Wrapped, and Message  RPC:  RPC services are the default in Axis  Axis will deserialize XML into Java objects which can be fed to your service, and will serialize the returned Java object(s) from your service back into XML.  Document  Document services do not use any encoding (so in particular, you won't see multiref object serialization or SOAP-style arrays on the wire) but DO still do XML<->Java databinding  Wrapped  Wrapped services are just like document services, except that rather than binding the entire SOAP body into one big structure, they "unwrap" it into individual parameters  Message  Message services receive and return arbitrary XML in the SOAP Envelope without any type mapping / data binding. If you want to work with the raw XML of the incoming and outgoing SOAP Envelopes, write a message service D:Program Files j2sdk_nbnetbeans3.5to
  • 22. Service Styles  <schema targetNamespace="http://commerce.com/PO"> <complexType name="POType"> <sequence> <element name="item" type="xsd:string"/> <element name="quantity" type="xsd:int"/> <element name="description" type="xsd:string"/> </sequence> </complexType> <element name="PurchaseOrder" type="POType"/>  document style service, this would map to a method like this:  public void method(PurchaseOrder po) In other words, the ENTIRE <PurchaseOrder> element would be handed to your method as a single bean with three fields inside it. On the other hand, • wrapped style service, it would map to a method like this:  public void purchaseOrder(String item, int quantity, String description)  Message Service public Element [] method(Element [] bodies); public SOAPBodyElement [] method (SOAPBodyElement [] bodies); public Document method(Document body); public void method(SOAPEnvelope req, SOAPEnvelope resp);
  • 23. Service Styles  Standard mappings from WSDL to Java
  • 24. An Example Axis Setup  Axis software in the form of xml-axis-beta3-bin.zip can be downloaded from http://archive.apache.org/dist/ws/axis/beta3  Extract the folder from zip file to c:/xml-axis folder  Set “%XML_AXIS% = c:/xml-axis” as environment variable  Set classpath = %XML_AXIS%libaxis.jar; %XML_AXIS% libcommons-logging.jar; %XML_AXIS%libjaxrpc.jar;c:xml-axisliblog4j-1.2.4.jar; %XML_AXIS%libtt- bytecode.jar; %XML_AXIS%libwsdl4j.jar;%XML_AXIS%libxmlParserAPIs.jar; %XML_AXIS%libsaaj.jar %JAVA_HOME%libtools.jar; Apache Tomcat Setup  Download Apache tomcat (jakarta-tomcat-4.1.31.exe) from http://mirror.tomato.it/apache/jakarta/tomcat-4/v4.1.31/bin  Set “CATALINA_HOME = C:Apache Tomcat 4.0” as environment variable  Also set “path=%path%;CATALINA_HOMEbin”  Add the following in server.xml (C:Apache Tomcat 4.0conf).  <Context path="/axis" docBase="C:xml-axiswebappsaxis" debug="0"/>  Start tomacat web server
  • 25. An Example A sample java Class public class HelloWorld{ public String sayHello(String reader){ System.out.println("Service Called"); return "Hi " + reader + " How are you"; } } Steps to Expose as Web Service  Write the following to a text file and name it as HelloWorldService.wsdd. <?xml version="1.0" encoding="UTF-8"?> <deployment xmlns=“http://xml.apache.org/axis/wsdd/” xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="HelloWorldService" provider="java:RPC"> <parameter name="allowedMethods" value=“sayHello"/> <parameter name="className" value="HelloWorld"/> </service> </deployment>
  • 26. An Example  Use the above wsdl file to expose as web service with the following command.  java -classpath "%classpath%;C:jarsaxis.jar;C:jarsjaxrpc.jar;C:jarscommons- logging-1.0.3.jar;C:jarscommons-discovery-0.2.jar;C:jarsjndi.jar;C:jarssaaj.jar;." org.apache.axis.client.AdminClient -h localhost -p 8080 -s WebservicesTest/servlet/AxisServlet "C:HelloWorldService.wsdd“  Test the exposed web service  http://localhost:8080/WebservicesTest/servlet/AxisServlet  Click on “wsdl” to view wsdl file in browser.  Use the following command to generate wsdl file for the exposed service  Java org.apache.axis.wsdl.Java2WSDL HelloWorld -l http://localhost:8080/WebservicesTest/services/HelloWorldService  Copy the wsdl file to %XML_AXIS% root  Use the following command to generate the stubs for given wsdl file  java org.apache.axis.wsdl.WSDL2Java C:xml-axisHelloWorldService.wsdl  For the generated stubs write a java class to access the web service.
  • 27. An Example Java code to access the web service via stubs import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; public class HelloWorldStubClient { public static void main(String[] args) { try{ //Fetch HelloWorldService object from Service Locator generated HelloWorldService hWorldService = new HelloWorldServiceLocator(); //Fetch actual service hosted from the service. HelloWorld hWorld = hWorldService.getHelloWorldService(); //call the Service method System.out.println(hWorld.sayHello("Harish")); }catch(ServiceException sExc){ sExc.printStackTrace(); }catch(RemoteException rExc){ rExc.printStackTrace(); } } }
  • 28. An Example  java org.apache.axis.utils.tcpmon
  • 29. Documentation  The JAX-WS 2.0 specification demands that the exception annotated with @WebFault must have two constructors and one method:  WrapperException(String message, FaultBean faultInfo) WrapperException(String message, FaultBean faultInfo, Throwable cause) FaultBean getFaultInfo() The WrapperException is replaced by the name of the exception, and FaultBean is replaced by the class name that implements the fault bean. The fault bean is a Java bean that contains the information of the fault and is used by the Web service client to know the cause for the fault.  Sample  @javax.xml.ws.WebFault(name="AddNumbersException",     targetNamespace="http://server.fromjava/jaxws") public class AddNumbersException_Exception extends Exception {     private fromjava.client.AddNumbersException faultInfo;     public AddNumbersException_Exception(String message, AddNumbersException faultInfo) {         super(message);         this.faultInfo = faultInfo;     }     public AddNumbersException_Exception(String message, AddNumbersException faultInfo,                                          Throwable cause) {         super(message, cause);         this.faultInfo = faultInfo;     }     public AddNumbersException getFaultInfo() {         return faultInfo;     } }
  • 30. Documentation HandlerChain Example: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <javaee:handler-chains xmlns:javaee=http://java.sun.com/xml/ns/javaee xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <javaee:handler-chain> <javaee:handler-chain-name>Service Framework Handlers</javaee:handler-chain-name> <javaee:handler> <javaee:handler-name>LoggingHandler</javaee:handler-name> <javaee:handler-class>com.test.handlers.LoggingHandler </javaee:handler-class> </javaee:handler> <javaee:handler> <javaee:handler-name>ThrottlingHandler</javaee:handler-name> <javaee:handler-class>com.test.handlers.ThrottlingHandler </javaee:handler-class> </javaee:handler> </javaee:handler-chain> </javaee:handler-chains>
  • 31. Documentation HandlerChain Example: Handler Interface public class LoggingHandler implements SOAPHandler<SOAPMessageContext> public boolean handleFault(SOAPMessageContext context) public boolean handleMessage(SOAPMessageContext context) public Set<QName> getHeaders()
  • 32. Documentation  URLs  http://today.java.net/pub/a/today/2006/09/19/asynchronous-jax- ws-web-services.html  http://java.sun.com/webservices/docs/2.0/tutorial/doc/  http://ws.apache.org/axis/java/user-guide.html#Introduction