Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2009 IBM Corporation 1 JAX-WS 2.1 Support For WS-Addressing In WebSphere Application Server V 7 18 March 2010.

Similar presentations


Presentation on theme: "© 2009 IBM Corporation 1 JAX-WS 2.1 Support For WS-Addressing In WebSphere Application Server V 7 18 March 2010."— Presentation transcript:

1 © 2009 IBM Corporation 1 JAX-WS 2.1 Support For WS-Addressing In WebSphere Application Server V 7 Sara_Mitchell@uk.ibm.com 18 March 2010

2 © 2009 IBM Corporation 2sara_mitchell@uk.ibm.com Introduction ■ IBM WebSphere Application Server V7 includes support for the Java API for XML-Based Web Services (JAX-WS) 2.1 specification. ■ JAX-WS 2.1 is a maintenance release of Java Specification Request (JSR) 224 that extends the functionality provided by the JAX-WS 2.0 specification with new capabilities. ■ The most significant new capability is support for Web Services Addressing (WS- Addressing) in the Application Programming Interface (API). ■ In this session, the speaker will work through the steps necessary to create a sample application that shows how to use this new WS-Addressing support to write a stateful web service. IBM Presentation Template Full Version

3 © 2009 IBM Corporation 3sara_mitchell@uk.ibm.com What is WS-Addressing? ■ EndpointReference (EPR) is simply a URI plus some additional information. An EPR can be flowed between services and clients and used by a client to target the endpoint that it represents. ■ Message Addressing Properties (MAPs) are standardised SOAP Headers that provide transport-neutral way of passing addressing information (eg, replyTo address). ■ MAPs may be useful to implementors of other WS* standards eg WS-AT but unlikely that an application will deal directly with the SOAP Headers. ■ EPRs can be sent in the body of the SOAP message and therefore used to propagate a reference to an endpoint back to the client. For example, WSA can then be used to provide stateful web service support. IBM Presentation Template Full Version

4 © 2009 IBM Corporation 4sara_mitchell@uk.ibm.com IBM history with WS-Addressing ■ IBM was an early implementer and so have an extensive API/SPI for WS-Addressing ■ WebSphere Application Server v6.0 provided support for WS-AtomicTransaction that used WS-Adressing support internally. NO PUBLIC SUPPORT! –This was the submission specification only ■ WebSphere Application Server v6.1 provided API/SPI support for customers use of WSAddressing v1.0. –Final specification and submission specification supported –WS-RF implementation in WAS IBM Presentation Template Full Version

5 © 2009 IBM Corporation 5sara_mitchell@uk.ibm.com Motivation for JAX-WS ■ Better platform independence for Java applications. –Using JAX-WS APIs, development of Web services and clients is simplified with better platform independence for Java applications. JAX-WS takes advantage of the dynamic proxy mechanism to provide a formal delegation model with a pluggable provider. This is an enhancement over JAX-RPC, which relies on the generation of vendor-specific stubs for invocation. ■ Annotations –JAX-WS supports the use of annotations based on the Metadata Facility for the Java Programming Language (JSR 175) specification, the Web Services Metadata for the Java Platform (JSR 181) specification and annotations defined by the JAX-WS 2.1 specification. ■ Invoking Web services asynchronously –With JAX-WS, Web services are called both synchronously and asynchronously. JAX- WS adds support for both a polling and callback mechanism when calling Web services asynchronously. ■ Using resource injection –JAX-WS uses Java EE 5 feature of resource injection to further simplify development of Web services. ■ This talk is not a comparison of JAX-RPC vs JAX-WS. See this developerWorks article for more on this topic: http://www.ibm.com/developerworks/library/ws-tip-jaxwsrpc.htmlhttp://www.ibm.com/developerworks/library/ws-tip-jaxwsrpc.html IBM Presentation Template Full Version

6 © 2009 IBM Corporation 6sara_mitchell@uk.ibm.com WebSphere, JAX-WS and WS-Addressing specifications support ■ JAX-WS 2.0 –Feature Pack for Web Services in WebSphere Application Server v6.1 ■ JAX-WS 2.1 –Support for WSAddressing 1.0 Core, SOAP Binding and WSDL Binding –WebSphere Application Server v7.0 ■ JAX-WS 2.2 –Support for WS-Addressing 1.0 Metadata specification ■ Websphere Application Server has integrated its existing support for the submission spec with the JAX-WS programming model. IBM Presentation Template Full Version

7 © 2009 IBM Corporation 7sara_mitchell@uk.ibm.com JAX-WS 2.1 API for WS-Addressing IBM Presentation Template Full Version ■ JAX-WS 2.1 EPR Creation –BindingProvider.getEndpointReference() –Endpoint.getEndpointReference() –MessageContext.getEndpointReference() ■ JAX-WS 2.1 EPR Propagation –Using JAXB 2.1 bind W3C EPR to W3CEndpointReference class –Marshall/Unmarshall W3CEndpointReference class using JAXB

8 © 2009 IBM Corporation 8sara_mitchell@uk.ibm.com Next... ■ EndpointReferences –Creating, using, converting ■ EndpointReferences –Fragile, WLM, HA ■ Enabling and Disabling WS-Addressing ■ Annotations for WS-Addressing in JAX-WS 2.1 IBM Presentation Template Full Version

9 © 2009 IBM Corporation 9sara_mitchell@uk.ibm.com Creating EPRs using an address ■ IBM API/SPI v6.1 onwards ■ JAX-WS programming model v7 onwards IBM Presentation Template Full Version

10 © 2009 IBM Corporation 10sara_mitchell@uk.ibm.com Creating EPRs using WSDL service name and endpoint (port) name ■ IBM API/SPI v6.1 onwards ■ JAX-WS programming model v7 onwards IBM Presentation Template Full Version

11 © 2009 IBM Corporation 11sara_mitchell@uk.ibm.com Creating EPRs to self. ■ IBM API/SPI v6.1 onwards –Use previous example i.e. EndpointReferenceManager.createEndpointReference(service_name, endpoint_qname) ■ JAX-WS 2.1 Submission Specification –No equivalent – use IBM API/SPI i.e. EndpointReferenceManager.createEndpointReference(service_name, endpoint_qname) ■ JAX-WS programming model v7 onwards: Creating an EPR to self via the WebServiceContext. IBM Presentation Template Full Version

12 © 2009 IBM Corporation 12sara_mitchell@uk.ibm.com Retrieving ReferenceParameters ■ Returning an EPR containing 'conversation' information, eg. CartID use the Reference Parameters. These can be accessed in the application code, or the EPR is simply used to target a message, at which point the Reference Parameters become SOAPHeader elements. ■ IBM API/SPI v6.1 onwards and JAX-WS 2.1 Submission specification ■ JAX-WS 2.1 programming model: IBM Presentation Template Full Version

13 © 2009 IBM Corporation 13sara_mitchell@uk.ibm.com Retrieving ReferenceParameters ■ JAX-WS 2.1 also allows you to use the javax.xml.ws.WebServiceContext to pass state information: ■ You must mark a variable as @Resource ■ This variable must be either of type Object (the default) or of type WebServiceContext. ■ WebServiceContext holds the MessageContext for the request being processed. ■ The MessageContext contains a bag of properties, both provided ones plus you can set your own. IBM Presentation Template Full Version

14 © 2009 IBM Corporation 14sara_mitchell@uk.ibm.com IBM proprietary SPI IBM Presentation Template Full Version

15 © 2009 IBM Corporation 15sara_mitchell@uk.ibm.com IBM proprietary SPI IBM Presentation Template Full Version

16 © 2009 IBM Corporation 16sara_mitchell@uk.ibm.com Integrating IBM proprietary SPI with JAX-WS 2.1 API for WS- Addressing IBM Presentation Template Full Version

17 © 2009 IBM Corporation 17sara_mitchell@uk.ibm.com Integrating IBM proprietary with JAX-WS example IBM Presentation Template Full Version ■ EndpointReferenceConverter class enables HA/WLM EndpointReferences to be created and used within a JAX-WS 2.1 application.

18 © 2009 IBM Corporation 18sara_mitchell@uk.ibm.com Wsimport -b ■ wsimport tool generates client-side artifacts, mapping endpoint references in the WS- Addressing Core 1.0 namespace to the W3CEndpointReference class. ■ To map endpoint references in the WS-Addressing Member Submission namespace to the SubmissionEndpointReference class you will need to specify the provided binding file, SubmissionEndpointReference.xjb ■ This is done using a -b parameter to the wsimport tool. ■ The binding file can be found in the util directory of your WebSphere Application Server installation.

19 © 2009 IBM Corporation 19sara_mitchell@uk.ibm.com Next... ■ EndpointReferences –Creating, using, converting ■ EndpointReferences –Fragile, WLM, HA ■ Enabling and Disabling WS-Addressing ■ Annotations for WS-Addressing in JAX-WS 2.1 IBM Presentation Template Full Version

20 © 2009 IBM Corporation 20sara_mitchell@uk.ibm.com EPR generation in WebSphere Application Server : Fragile EPRs ■ WebSphere Application Server will generate the correct URI address for the EPR based on your deployment. ■ The EPR's address depends on whether the endpoint will be accessed directly or via an intermediary such as a proxy or firewall. ■ The simplest use of WS-Addressing is an EPR containing a URI to a service. ■ The host name and port of the node hosting the endpoint will be used to generate the EPR [address] URI. ■ This can be referred to as a Fragile EPR. It is valid only whilst that specific endpoint is available. IBM Presentation Template Full Version

21 © 2009 IBM Corporation 21sara_mitchell@uk.ibm.com Fragile EPRs with intermediary ■ Nothing much changes if there is an HTTP or IBM Proxy Server for WebSphere in front of WebSphere Application Server ■ The [address] URI will now point to the host and port configured for the intermediary to front this endpoint. IBM Presentation Template Full Version

22 © 2009 IBM Corporation 22sara_mitchell@uk.ibm.com WLM'able and non-WLM'able EPRs ■ There's more to IBM's EPR generation than first meets the eye. EPRs created by the WebSphere Application Server API will have some additional "value add" when used in a Websphere environment. ■ These EPRs, however, may still be used by non- Websphere clients. ■ An example of WebSphere Application Server workload-managed (WLM) cluster environment. ■ Messages (requests or responses) targeted at the EPR will be automatically workload managed as long as the server hosting the endpoint is fronted by a WebSphere Application Server proxy or WebSphere Application Server client in the same administrative cell. IBM Presentation Template Full Version

23 © 2009 IBM Corporation 23sara_mitchell@uk.ibm.com Stateful Web Services – Highly Available EPRs ■ So, what if you don't want the EPR to be workload managed. ■ A ShoppingCart instance might be a stateful session bean retaining in-memory state data. ■ Every request targeted at its EPR must be targeted at the same stateful session bean. ■ In a distributed environment, by creating the EPR and passing in an additional parameter (a reference to the stateful session bean) to the createEndpointReference method, you can ensure that affinity is maintained for requests targeted at the EPR in the cluster topologies described above. ■ Moreover, this support is fully integrated with the WebSphere Application Server stateful session bean high availability support. So, if the node containing your stateful session bean suddenly goes down, and the bean is failed over to another node, your EPR will still work. ■ You can also prevent WLM for non stateful session beans by passing a null reference to the createEndpointReference method. This is useful in a more general case where affinity is required to a specific server (for example, because an endpoint implementation locally caches state on the server on which the endpoint was created). IBM Presentation Template Full Version

24 © 2009 IBM Corporation 24sara_mitchell@uk.ibm.com Next... ■ EndpointReferences –Creating, using, converting ■ EndpointReferences –Fragile, WLM, HA ■ Enabling and Disabling WS-Addressing ■ Annotations for WS-Addressing in JAX-WS 2.1 IBM Presentation Template Full Version

25 © 2009 IBM Corporation 25sara_mitchell@uk.ibm.com Enabling and disabling WS-Addressing IBM Presentation Template Full Version ■ Service clients: WS-Addressing is disabled by default ■ Attach a Web services policy set to the client and optionally: –Enable mandatory WS-Addressing –Enable WS-Policy policy sharing ■ WebServiceFeature in client code ■ Specify the UsingAddressing required=true/false element in the WSDL document for the service. Not for dispatch clients that don't use the WSDL. ■ Set the com.ibm.websphere.webservices.use.asyn c.mep property on the client request context. ■ Use the IBM proprietary WS-Addressing SPI to add message-addressing properties to the message request context. ■ Service providers: WS-Addressing is enabled by default ■ Attach a Web services policy set to the client and: –Enable mandatory WS-Addressing –Enable WS-Policy policy sharing ■ Annotations in service code ■ Specify the UsingAddressing required=true/false element in the WSDL document for the service. If the service uses the Addressing annotation and you generate the WSDL document from the code, the UsingAddressing element already exists. This method does not apply to Dispatch clients, because these clients do not use the WSDL document. ■ Use the IBM proprietary WS-Addressing SPI to add message-addressing properties to the message request context.

26 © 2009 IBM Corporation 26sara_mitchell@uk.ibm.com Enabling WS-Addressing in WAS ■ Attach a WebSphere Web services policySet –Select WS-Addressing is mandatory to specify that WS-Addressing information must be included in SOAP message headers. For servers, this setting means that the server returns a fault if it receives a message that does not contain a WS-Addressing header. For clients, this setting means that WS-Addressing headers are always added to SOAP messages. If you have enabled WS-Policy, this requirement is communicated between servers and clients that support WS-Policy. –In the Messaging style box, select the message exchange pattern to use: Synchronous and asynchronous. The targeting of response messages is not restricted. Synchronous only. Response messages must be targeted at the WS-Addressing anonymous URI. Asynchronous only. Response messages must not be targeted at the WS- Addressing anonymous URI. IBM Presentation Template Full Version

27 © 2009 IBM Corporation 27sara_mitchell@uk.ibm.com Enabling WS-Addressing in WAS ■ Client side WS-Policy –Provider policy only. Configure the client based solely on the policy of the service provider. This option is available when a client policy set is not attached. –Client and provider policy. Configure the client based on both the client policy set and the policy of the service provider. This option is available when a client policy set is attached. ■ Server side WS-Policy –Include the policy configuration of the service provider in the WSDL. The WSDL is then available to publish, or to obtain by using an HTTP Get request. –Enable the Web Services Metadata Exchange (WS-MetadataExchange) protocol so that the policy configuration of the service provider is included in the WSDL and is available to a WS-MetadataExchange GetMetadata request. –An advantage of using the WS-MetadataExchange protocol is that you can apply message-level security to WS-MetadataExchange GetMetadata requests by using a suitable system policy set. IBM Presentation Template Full Version

28 © 2009 IBM Corporation 28sara_mitchell@uk.ibm.com Enable WSAddressing on the service client using JAX-WS Features ■ JAX-WS 2.1 introduces 'features' for programmatic control of the client. ■ Provided in JAX-WS 2.1 –WS-Addressing 1.0 Core specification namespace http://www.w3.org/2005/08/addressing –javax.xml.ws.soap.AddressingFeature extends javax.xml.ws.WebServiceFeature ■ Proprietary, provided by WebSphere Application Server: –WS-Addressing submission specification namespace http://schemas.xmlsoap.org/ws/2004/08/addressing –com.ibm.websphere.wsaddressing.jaxws21.SubmissionAddressingFeature extends javax.xml.ws.WebServiceFeature ■ Overrides settings in the WSDL ■ Format: –Optional parameters: WS-Addressing is enabled :: true/false WS-Addressing is required :: required Examples : (true, required), (false) The default settings are that WS-Addressing is enabled but not required. IBM Presentation Template Full Version

29 © 2009 IBM Corporation 29sara_mitchell@uk.ibm.com Enable WSAddressing on the provider using JAX-WS Annotations ■ JAX-WS 2.1 introduces specific WS-Addressing annotations that mirror Features ■ Provided in JAX-WS 2.1 javax.xml.ws.soap.Addressing –WS-Addressing 1.0 Core specification namespace http://www.w3.org/2005/08/addressing ■ Proprietary in WebSphere Application Server v7 com.ibm.websphere.wsaddressing.jaxws21.SubmissionAddressing –WS-Addressing submission specification namespace http://schemas.xmlsoap.org/ws/2004/08/addressing ■ Format: –Optional parameters: WS-Addressing is enabled :: true/false. If WS-Addressing is disabled then any WS-Addressing headers in inbound requests will be ignored. WS-Addressing is required :: true will cause a fault to be returned if WS-Addressing headers not received. The default settings are that WS-Addressing is enabled but not required. IBM Presentation Template Full Version

30 © 2009 IBM Corporation 30sara_mitchell@uk.ibm.com Enabling and disabling WS-Addressing in the service client ■ Set the com.ibm.websphere.webservices.use.async.mep property on the client request context. ■ Specify the UsingAddressing required=true/false element in the WSDL document for the service. If the service uses the Addressing annotation and you generate the WSDL document from the code, the UsingAddressing element already exists. This method does not apply to Dispatch clients, because these clients do not use the WSDL document. ■ Use the IBM proprietary WS-Addressing SPI to add message-addressing properties to the message request context. Source If Applicable IBM Presentation Template Full Version

31 © 2009 IBM Corporation 31sara_mitchell@uk.ibm.com Next... ■ EndpointReferences –Creating, using, converting ■ EndpointReferences –Fragile, WLM, HA ■ Enabling and Disabling WS-Addressing ■ Annotations for WS-Addressing in JAX-WS 2.1 IBM Presentation Template Full Version

32 © 2009 IBM Corporation 32sara_mitchell@uk.ibm.com @Action and @FaultAction annotations ■ New annotations to support the mapping of WS-Addressing actions to WSDL operations. ■ @Action annotation allows an action to be explicitly associated with the input, and output of a WSDL operation. ■ @FaultAction annotation is used inside of an @Action annotation to associate each fault with an action. ■ @Addressing annotation is required in order to use the @Action and @FaultAction annotations, otherwise they are ignored. ■ When an SEI is generated using the WSDL, the @Action and @FaultAction annotations are not added automatically and must be manually added to the SEI.

33 © 2009 IBM Corporation 33sara_mitchell@uk.ibm.com What can you do with this in your applications? ■ I have a Web Service for an online shop called BuildingSuppliesShop ■ It has the following methods: –W3CEndpointReference newShoppingCart(); –addItem(String item, int quantity); –addToAccount(String accountName, String cartID); ■ My service will be Highly Available and store state relating to this shopper. IBM Presentation Template Full Version

34 © 2009 IBM Corporation 34sara_mitchell@uk.ibm.com An example... IBM Presentation Template Full Version WebSphere Application Server Cluster Administrative Cell Firewall Proxy Server for WebSphere

35 © 2009 IBM Corporation 35sara_mitchell@uk.ibm.com An example... IBM Presentation Template Full Version WebSphere Application Server Cluster Administrative Cell Firewall Proxy Server for WebSphere

36 © 2009 IBM Corporation 36sara_mitchell@uk.ibm.com An example... IBM Presentation Template Full Version WebSphere Application Server Cluster Administrative Cell Firewall Proxy Server for WebSphere

37 © 2009 IBM Corporation 37sara_mitchell@uk.ibm.com An example... IBM Presentation Template Full Version WebSphere Application Server Cluster Administrative Cell Firewall Proxy Server for WebSphere

38 © 2009 IBM Corporation 38sara_mitchell@uk.ibm.com An example... IBM Presentation Template Full Version WebSphere Application Server Cluster Administrative Cell Firewall Proxy Server for WebSphere

39 © 2009 IBM Corporation 39sara_mitchell@uk.ibm.com An example... IBM Presentation Template Full Version WebSphere Application Server Cluster Administrative Cell Firewall Proxy Server for WebSphere

40 © 2009 IBM Corporation 40sara_mitchell@uk.ibm.com An example... IBM Presentation Template Full Version WebSphere Application Server Cluster Administrative Cell Firewall Proxy Server for WebSphere

41 © 2009 IBM Corporation 41sara_mitchell@uk.ibm.com Summary ■ IBM's API/SPI for WS-Addressing ■ JAX-WS 2.1 API for WS-Addressing ■ Integration capabilities in WebSphere Application Server ■ Features and Annotations for WS-Addressing ■ Enabling and disabling WS-Addressing ■ Stateful Web Services with JAX-WS 2.1 ■ Highly Available Web Services with WebSphere Application Server IBM Presentation Template Full Version

42 © 2009 IBM Corporation 42sara_mitchell@uk.ibm.com Useful Links ■ http://www.ibm.com/developerworks/webservices/library/ws-JAXsupport/index.html http://www.ibm.com/developerworks/webservices/library/ws-JAXsupport/index.html ■ http://www.ibm.com/developerworks/webservices/library/ws-soa-wsawsa/ http://www.ibm.com/developerworks/webservices/library/ws-soa-wsawsa/ ■ http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.b ase.doc/info/aes/ae/cwbs_wsa.html http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.b ase.doc/info/aes/ae/cwbs_wsa.html ■ WS-Addressing development lead : katherine_sanders@uk.ibm.com ■ Me : sara_mitchell@uk.ibm.com IBM Presentation Template Full Version


Download ppt "© 2009 IBM Corporation 1 JAX-WS 2.1 Support For WS-Addressing In WebSphere Application Server V 7 18 March 2010."

Similar presentations


Ads by Google