33
JAX-WS 2.x and WSIT (Project Tango) Alexis Moussine-Pouchkine Sun Microsystems, Inc.

JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

JAX-WS 2.x andWSIT (Project Tango)

Alexis Moussine-PouchkineSun Microsystems, Inc.

Page 2: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

2

Agenda

• JAX-WS basics> Architecture> Annotation based programing model

• More advanced JAX-WS topics> Handlers> Dispatch / Provider

• WSIT (Project Tango)> Web Services Interop Technologies

Page 3: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

3

JAX-WS definition

• New, easy-to-use Web Services API• Successor to JAX-RPC 1.x• JAX-WS 2.0 Part of Java EE 5• POJO – Plain Old Java Objects• Descriptor-free programing model• Layered architecture• Transport and Protocol independence• Integrated use of JAXB 2.0• JAX-WS 2.0 also part of Java SE 6

Page 4: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

4

Standards

• JAX-WS Standards> SOAP 1.1/1.2> WSDL 1.1> WS-I Basic Profile (BP) 1.x> MTOM, ...

• Foundation for full WS-* compliant stack> WSIT / Project Tango> Tested interoperability with .Net 3.0's WCF

(Windows Communication Foundation)

Page 5: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

5

JAX-WS 2.1 Layered Architecture

Application Logic

Strongly TypedAnnotated Classes

Messaging LayerDispatch / Provider API

Page 6: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

6

Server-side Programming Model

• Starting from a POJO> Write a POJO implementing the service> Add @WebService annotation> Build and deploy

>WSDL file generated automatically

• Starting from a WSDL file> Generate implementation> Implement Server Endpoint Interface> Build and deploy

Page 7: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

7

JAX-WS Web Service Implementation

package endpoint;

import javax.jws.WebService;

@WebServicepublic class Bonjour {

public String ditBonjour(String nom) {return "Bonjour " + nom;

}

}

Application Logic

Annotated Classes

Dispatch / Provider

Page 8: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

8

How simple did it get?

• Public methods become web service operations• Default values for service name, etc.• WSDL generated automatically @

http://host/webcontext/Bonjour?wsdl

package endpoint;

import javax.jws.WebService;

@WebServicepublic class Bonjour {

public String ditBonjour(String nom) {return "Bonjour " + nom;

}

}

Page 9: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

9

Transactional Web Service

package endpoint;

import javax.jws.WebService;import javax.ejb.Stateless;

@WebService@Statelesspublic class Bonjour {

public String ditBonjour(String name) {return "Bonjour " + name;

}

}

Page 10: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

10

Client-side Programming Model

wsimport http://host/webcontext/Bonjour?wsdl

• No factories yet the code is fully portable• XML is completely hidden from programmer

BonjourService service = new BonjourService();

Bonjour port = service.getBonjourPort();

String nom = "Peter";

String result = port.ditBonjour(nom);

Page 11: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

11

Demo

Page 12: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

12

Web Service reference injection

@Stateless

public class MySessionBean implements MySessionLocal {

@WebServiceRef

private BonjourService service;

public MySessionBean() {

client.Bonjour port = service.getBonjourPort();

String nom = "Peter";

String result = port.ditBonjour(nom);

System.out.println("Result = "+result);

}

}

Page 13: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

13

Finer-grained Annotation Attributes

@WebService(serviceName = "BonjourService", portName = "BonjourPort",endpointInterface = "Bonjour",targetNamespace = "http://endpoint/", wsdlLocation = ".../BonjourService.wsdl")

public class Bonjour {

@WebMethod(action="sayHello", operationName="OpName")

public String ditBonjour (@WebParam(name = "name") String nom) {

return "Bonjour " + name;

}

}

Page 14: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

14

JAX-WS Handlers

• Protocol Handler> May change protocol specifics> Corner cases or specific protocol (profile)

• Logical/Message handler> Protocol agnostic> Used to access the message payload

• Chaining of handlers is possible

Page 15: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

15

Logical/Message Handler

public class MessageHandler implements SOAPHandler<SOAPMessageContext> {

public boolean handleMessage ( SOAPMessageContext messageContext ) { SOAPMessage msg = messageContext.getMessage(); ..... return true; } public Set<QName> getHeaders() { ... } public boolean handleFault ( SOAPMessageContext messageContext ) { ... } public void close(MessageContext context) { ... }}

chaining

Page 16: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

16

Messaging Layer

• Use-cases> Dynamic Client (management console)> Dynamic Server (gateway)> Protocol with no established service

description (RESTful Web Services)

• Server-side Provider<T>> Source for any XML messages> DataSource for MIME or binary data> SOAPMessage for SOAP-based services

• Client-side Dispatch<T>> Future<?> invokeAsync (T message, AsyncHandler<T> handler)

• More Control comes at a complexity cost

Application Logic

Annotated Classes

Dispatch / Provider

Page 17: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

17

Web Services Recommendations

• Control your environment when possible> Use Document/Literal

>The solution going forward for interop across WS Stacks>JAX-WS 2.x does not support RPC/Encoded

> Latest “compatible” version of Web services toolkits>Things change with point releases

> Debugging, tracing and logging>Use tools to their full extent

> Thinking about exceptions>Use SOAP Fault to describe error

Page 18: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

18

JAX-WS Summary

• Platform for WS-I BP 1.1-based WS• Annotations reduce need for descriptors• Clean integration with JAXB• Support for traditional and RESTful WS• Fully integrated into NetBeans• JAX-WS part of Java EE 5 and Java SE 6 platforms

Page 19: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

19

What is WSIT?

• Web Services Interoperability Technologies> Also known as “Project Tango”> Build as an extension of JAX-WS 2.x

• Goals:> Implementation of WS-* specifications> Interoperability with Microsoft Windows

Communication Foundation(WCF, a .NET 3.0 component)

> Foundation for building SOA

Page 20: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

20

Web Services Stack

Page 21: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

21

Optimizing Communication

• Wire format optimization > MTOM/XOP (W3C)

>Avoids large binary base64 encoding>Uses MIME attachments for binary data>More interoperable

> FastInfoset (ITU-T/ISO)>Encode complete XML infosets in binary>Parsing performance: 3-10X>Compaction performance: 50% on average>Better performance

• Transparent to application

Page 22: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

22

Optimizing Communication

• Security optimization (WS-SecureConversation)• Establish shared context on multi-message

exchange• Use context to generate derived keys on

subsequent messages• Increases security and performance• Transparent to application

Page 23: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

23

WS-ReliableMessaging

• Before WS-ReliableMessaging:> Reliable protocols based on TCP> Point-to-point> Done at the application level

• Bring reliability to SOAP (protocol) layer• Recover from lost/mis-ordered messages• Enable use of alternate transports (i.e., non-TCP/IP)• Transparent to application

Page 24: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

24

WS-AtomicTransaction

• Uses WS-Coordination• All operations in TX boundary succeed or rollback• New to Web Services • Same as EJB/RMI-IIOP TX

Page 25: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

25

Transactions in Action

@j avax. j ws. WebServi ce @j avax. ej b. St at el ess @j avax. ej b. Transact i onManagement ( CONTAI NER)  publ i c  cl ass  Wi rer  {  

      @j avax. j ws. WebMet hod       @j avax. ej b. Transact i onAt t ri but e( REQUI RED)        voi d  wi reFunds( . . . )   t hrows  . . .   {              websrvc1. wi t hdrawFromBankX( . . . ) ;              websrvc2. deposi t I nt oBankY( . . . ) ;      }  }  

Page 26: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

26

WS-Trust

• Define additional primitives and extensions on WS-Security

• Issuing, renewing, validating security tokens• Establish and broker trust relationships• Mutual trust between heterogeneous trust authorities• Transparent to application

Page 27: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

27

Web Services Stack

Page 28: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

28

WSIT Programming Model

• No runtime APIs for WSIT• Developer uses JAX-WS and EJB APIs• WSDL contains WS-Policy metadata

> Control use of WSIT runtime> Enables portable dynamic negotiation using WS-

MetadataExchange> WS-Policy can be generated using NetBeans WSIT

module> Also available as client WSIT config file

Page 29: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

29

Demo

Page 30: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

30

JAX-WSjax-ws.dev.java.net

WSIT (whiz-it)wsit.dev.java.net

WSIT NetBeans Modulewebsvc.netbeans.org/wsit

Page 31: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

31

“The Clear Choice”

See website for latest stats

Project GlassFish v2

Simplifying Java application Development with Java EE 5 technologies

Includes JWSDP, EJB 3.0, JSF 1.2, JAX-WS and JAXB 2.0

Supports > 20 frameworks and apps

Included in Sun Java System Application Server 9.x

Free to download and free to deploy

Over 1800 members and 300,000 downloads

Integrated with NetBeans and other IDEs

http://glassfish.java.net

Page 32: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

32

Summary

• JAX-WS 2.x is easier to use and more powerful than its predecessor JAX-RPC 1.1

• JAX-WS part of the Java EE 5 and Java SE 6 platforms• Layered design hides the complexity• Extensible at the protocol and transport level• Fully interoperable with other WS-* stacks using WSIT• Programming model ranges from simple to flexible

Page 33: JAX-WS 2.x and WSIT (Project Tango) · 16 Messaging Layer •Use-cases >Dynamic Client (management console) >Dynamic Server (gateway) >Protocol with no established service

JAX-WS 2.x andWSIT (Project Tango)

Alexis Moussine-Pouchkinehttp://blogs.sun.com/[email protected]