LibraryToggle FramesPrintFeedback

Web Service Development Pattern

Overview

With JAX-WS, you can develop Web services using one of two development approaches:

  • Code-first

    Considered the easier approach, code-first (or java-first) is favored for small-scale, tactical integrations. Code-first services use Java annotations in the code, from which WSDL and XSD artifacts are generated on-the-fly.

    The code-first approach is useful when you have existing Java code that implements a set of functionality that you want to expose as part of a service-oriented application, or you just don't want to use WSDL to define your interface. Using JAX-WS annotations in your code, you can add the information required to service-enable a java class and also to create a Service Endpoint Interface (SEI) that can be used in place of a WSDL contract.

    For more information, see Starting from Java Code in Developing Applications Using JAX-WS.

  • Contract-first

    Contract-first (or WSDL-first) is preferred for large-scale, strategic Service Oriented Architecture (SOA) integrations. Contract-first services are typically modular, platform agnostic, and better attend to versioning.

    The contract-first approach uses a WSDL document to define the operations a service exposes and the data that is exchanged with it. Using the WSDL document, you generate starting-point code for the service provider, then add the business logic to it using the Java APIs.

    For more information, see Starting from WSDL in Developing Applications Using JAX-WS.

Data exchange format

Service-oriented design abstracts data into a common exchange format, typically an XML grammar defined in XML schema. The JAX-WS specification calls for marshalling XML schema types into Java objects, in accordance with the Java Architecture for XML Binding (JAXB) specification.

JAXB defines bindings for mapping between XML schema constructs and Java objects and rules for marshalling the data. It also defines an extensive customization framework for controlling how data is handled. For details, see JAXB data bindings.

JAXB data bindings

JAXB enables you to store and retrieve data in memory in any XML format, without implementing a set of specific XML loading and saving routines for the program's class structure. It also enables you to map Java classes to XML representations, so you can:

  • Marshal Java objects into XML

  • Unmarshal XML back into Java objects

JAXB uses Java annotation in combination with files found on the classpath to build the mapping between XML and Java objects. It supports both code-first and contract-first programming.

JAXB is extremely useful when your service specification is complex and changes regularly, because changing the XML schema definitions to maintain synchronization with the java definitions is time consuming and error prone.

For more details, see Working with Data Types in Developing Applications Using JAX-WS.

[Note]Note

In the Major Widgets use case, JAX-WS is used to create a front-end order entry application on each of the in-store terminals. See Major Widgets Phase One Solution.

Comments powered by Disqus