Service Oriented Architecture: 12
JAX-WS-XML
Prof Neeraj Bhargava
Vaibhav Khanna
Department of Computer Science
School of Engineering and Systems Sciences
Maharshi Dayanand Saraswati University Ajmer
JAX-WS - XML
• The Java API for XML Web Services (JAX-WS) is a
highlevel API for consuming and providing web
services.
• JAX-WS replaces the older JAX-RPC API.
• JAX-WS doesn’t require you to know very much
about XML or WSDL. The entire XML layer is
hidden from developers, who can instead just
work with objects generated by web services
tools that come with Java SE 6 and EE 5 onwards.
JAX WS objects
• These objects encapsulate all of the work of
creating SOAP messages, invoking the service,
and parsing responses, hiding significant
complexity from developers.
• Originated to address the need of a binding
language to convert (marshal) from Java to
XML and back again.
What is JAX-WS?
• JAX-WS is the core Java web service technology
(standard for Java EE):
• JAX-WS is the standard programming model /
API for WS on Java (JAX-WS became a standard
part of Java as of version 1.6).
• JAX-WS is platform independent (many Java
platforms like Glassfish, Axis2 or CXF support
JAX-WS).
• Services developed on one platform can be
easily ported to another platform.
• JAX-WS makes use of annotations like
@WebService. This provides better scalability (no
central deployment descriptor for different WS
classes is required).
• JAX-WS uses the POJO concept (use of plain Java
classes to define web service interfaces).
• JAX-WS replaces / supersedes JAX-RPC (= old Java
web services, basically RMI over web service). JAX-WS
is more document orientiented instead of RPC-
oriented.
• Glassfish is the JAX-WS reference implementation
Glassfish = Reference implementation
for JAX-WS
• Glassfish: Java EE reference implementation (RI), reference Java
application server.
• Metro: WS stack as part of Glassfish (consists of JAX-WS and WSIT
components).
• JAXB: Data binding (bind objects to XML documents or
fragments).
• SAAJ: SOAP with Attachments API for Java.
• JAX-WS: Java core web service stack.
• WSIT: Web Services Interoperability Technologies (enables interop
with .Net).
• JAXR: Java API for XML Registries (WS registry).
• StaX: Streaming API for XML.
Three Approaches
• There are three different ways to approach developing
applications with JAX-WS:
• The WSDL to Java approach Point to a WSDL and use
tools such as wsimport to generate portable web
service artifacts.
• The Java to WSDL approach Create a Service Endpoint
Interface as Java source files. Use them as inputs to
generate the WSDL and other required portable
artifacts.
• The Start from Java and WSDL approach This can be a
smart way of working. Write Java classes and let wsgen
create WSDL and schema for you.
POJO / Java bean as web service class
• Web services through simple annotations:
• The programming model of JAX-WS relies on
simple annotations.
• This allows to turn existing business classes
(POJOs) into web services with very little effort.
• Web service endpoints are either explicit or
implicit, depending on the definition or absence
of a Java interface that defines the web service
interface
• Implicit SEI (Service Endpoint Interface):
• Service does not have an explicit service
interface, i.e. the class itself is the service
interface.
• The service bean has an associated service
endpoint interface (reference to interface).
POJO Explicit SEI:
• public interface IHello
• // Explicit endpoint interface //
• {
• @WebMethod
• public String sayHello() {...}
• }
• @WebService(endpointInterface=IHello)
• // Reference to explicit service endpoint interface //
• public class HelloWorld
• {
• public String sayHello() {...}
• }
Assignment
• Describe the Java API for XML based web
services.
• Thank You

Soa 12 jax ws-xml Java API for web services

  • 1.
    Service Oriented Architecture:12 JAX-WS-XML Prof Neeraj Bhargava Vaibhav Khanna Department of Computer Science School of Engineering and Systems Sciences Maharshi Dayanand Saraswati University Ajmer
  • 2.
    JAX-WS - XML •The Java API for XML Web Services (JAX-WS) is a highlevel API for consuming and providing web services. • JAX-WS replaces the older JAX-RPC API. • JAX-WS doesn’t require you to know very much about XML or WSDL. The entire XML layer is hidden from developers, who can instead just work with objects generated by web services tools that come with Java SE 6 and EE 5 onwards.
  • 3.
    JAX WS objects •These objects encapsulate all of the work of creating SOAP messages, invoking the service, and parsing responses, hiding significant complexity from developers. • Originated to address the need of a binding language to convert (marshal) from Java to XML and back again.
  • 4.
    What is JAX-WS? •JAX-WS is the core Java web service technology (standard for Java EE): • JAX-WS is the standard programming model / API for WS on Java (JAX-WS became a standard part of Java as of version 1.6). • JAX-WS is platform independent (many Java platforms like Glassfish, Axis2 or CXF support JAX-WS). • Services developed on one platform can be easily ported to another platform.
  • 5.
    • JAX-WS makesuse of annotations like @WebService. This provides better scalability (no central deployment descriptor for different WS classes is required). • JAX-WS uses the POJO concept (use of plain Java classes to define web service interfaces). • JAX-WS replaces / supersedes JAX-RPC (= old Java web services, basically RMI over web service). JAX-WS is more document orientiented instead of RPC- oriented. • Glassfish is the JAX-WS reference implementation
  • 6.
    Glassfish = Referenceimplementation for JAX-WS • Glassfish: Java EE reference implementation (RI), reference Java application server. • Metro: WS stack as part of Glassfish (consists of JAX-WS and WSIT components). • JAXB: Data binding (bind objects to XML documents or fragments). • SAAJ: SOAP with Attachments API for Java. • JAX-WS: Java core web service stack. • WSIT: Web Services Interoperability Technologies (enables interop with .Net). • JAXR: Java API for XML Registries (WS registry). • StaX: Streaming API for XML.
  • 7.
    Three Approaches • Thereare three different ways to approach developing applications with JAX-WS: • The WSDL to Java approach Point to a WSDL and use tools such as wsimport to generate portable web service artifacts. • The Java to WSDL approach Create a Service Endpoint Interface as Java source files. Use them as inputs to generate the WSDL and other required portable artifacts. • The Start from Java and WSDL approach This can be a smart way of working. Write Java classes and let wsgen create WSDL and schema for you.
  • 8.
    POJO / Javabean as web service class • Web services through simple annotations: • The programming model of JAX-WS relies on simple annotations. • This allows to turn existing business classes (POJOs) into web services with very little effort. • Web service endpoints are either explicit or implicit, depending on the definition or absence of a Java interface that defines the web service interface
  • 9.
    • Implicit SEI(Service Endpoint Interface): • Service does not have an explicit service interface, i.e. the class itself is the service interface. • The service bean has an associated service endpoint interface (reference to interface).
  • 10.
    POJO Explicit SEI: •public interface IHello • // Explicit endpoint interface // • { • @WebMethod • public String sayHello() {...} • } • @WebService(endpointInterface=IHello) • // Reference to explicit service endpoint interface // • public class HelloWorld • { • public String sayHello() {...} • }
  • 11.
    Assignment • Describe theJava API for XML based web services. • Thank You