8/6/2019 wsaddressing
1/33
WS-AddressingWS-Addressing
8/6/2019 wsaddressing
2/33
2
Topics
What is and Why WS-Addressing?
WS-Addressing and WSDL
Messaging Addressing Properties
WS-Addressing and Stateful Web service
8/6/2019 wsaddressing
3/33
What is & WhyWhat is & WhyWS-Addressing?WS-Addressing?
8/6/2019 wsaddressing
4/33
4
Motivation for WS-Addressing
SOAP does not provide a standard way to specify> Where a message is going (destination)> How to return a response>
Where to report an error. Those details have historically been left up to the
transport layer.> For example, when a standard SOAP request is sent
over HTTP, the URI of the HTTP request serves as themessage's destination.
> The message response is packaged in the HTTPresponse and received by the client over the HTTP
connection.
8/6/2019 wsaddressing
5/33
5
WS-Addressing
Provides transport-neutral mechanisms to addressWeb services and messages> The transport-neutrality is achieved by normalizing the
information typically shared between transport protocolsand messaging systems.
To serve this purpose, WS-Addressing defines twonew constructs>
Endpoint Reference (EPR)> MessageInformation Headers
Supported from JAX-WS 2.1
8/6/2019 wsaddressing
6/33
6
WS-Addressing
Defines standard ways to route a message overmultiple transports or direct a response to a thirdparty.>
For example, a client application might send a requestover JMS and ask to receive the response through e-mailor SMS.
8/6/2019 wsaddressing
7/337
Transport Dependent Addressing
A SOAP 1.2 message, without WS-Addressing, sent over HTTP transport looks like:(001) POST /fabrikam/Purchasing HTTP 1.1/POST(002) Host: example.com(003) SOAPAction: http://example.com/fabrikam/SubmitPO(004)
(005) (006) (007) (008) uuid:e197db59-0982-4c9c-9702-4234d204f7f4(009) (010) (011) (012) ...(013) (014)
Line (001) - (003) shows the HTTP transport headers. Line (005) - (014) shows the
SOAP message in HTTP body.
8/6/2019 wsaddressing
8/338
Transport Dependent Addressing
The host (example.com), the dispatch method (POST) andthe URL to dispatch to ( /fabrikam/Purchasing) are in theHTTP transport headers
If the message is to be sent over an alternate transport,such as SMTP, then the information conveyed in HTTPtransport headers need to be mapped to SMTP specificheaders. On the server side, to dispatch successfully, aWeb service stack has to gather the information from the
SMTP (as opposed to HTTP) headers and the SOAPmessage.
8/6/2019 wsaddressing
9/339
Transport Dependent Addressing
Also in the above message, there is no standard header toestablish the identity of a message.
In this case, MessageID header defined in the namespacebound to wombatprefix is used but is application specificand is thus not re-usable.
8/6/2019 wsaddressing
10/3310
Transport Independent Addressing viaWS-AddressingA SOAP 1.2 message, with WS-Addressing, sent over HTTP transport looks like:(001) POST /fabrikam/Purchasing HTTP 1.1/POST(002) Host: example.com(003) SOAPAction: http://example.com/fabrikam/SubmitPO(004)
(005) (006) (007) (008) uuid:e197db59-0982-4c9c-9702-4234d204f7f4(009) (010)
(011) mailto:[email protected](012) (013) (014) http://example.com/fabrikam/SubmitPO(015) (016) (017) (018) ...(019) (020)
8/6/2019 wsaddressing
11/33
WS-Addressing &WS-Addressing &WSDLWSDL
8/6/2019 wsaddressing
12/3312
WS-Addressing and WSDL
WS-Addressing extends and incorporates someconcepts from WSDL, but there is no explicitdependency between the two.
Web services developers can use either or both,depending on their needs.
WS-Addressing makes use of WSDL's "service" and"port" concepts
8/6/2019 wsaddressing
13/33
Message InformationMessage InformationHeadersHeaders
8/6/2019 wsaddressing
14/3314
Message Information Headers
xs:anyURI
xs:anyURI
xs:anyURIxs:anyURI
endpoint-reference
endpoint-referenceendpoint-reference
8/6/2019 wsaddressing
15/3315
Message Information Headers
Define the full set of addressing information that canbe attached to a SOAP message.
Most of the fields are optional; the only required
fields are the To andAction fields, each of whichspecifies a URI.
8/6/2019 wsaddressing
16/3316
To URI & Action URI
To URI specifies the "where" and theAction URIspecifies the "what":
Action URI specifies service
The separation of the To URI and theAction URIallows for lots of flexibility in configuring web servicedestinations.> For example, a request sent by e-mail or SMS may go to
a destination that is not represented by a WSDL porttype.> For example, an e-mail address might receive requests
for multiple services, all identified by theirAction URIvalues.
8/6/2019 wsaddressing
17/3317
Message Addressing Properties
mailto:[email protected]://example.com/aservice
// ...
mailto:[email protected]://example.com/anotherservice
// ...
8/6/2019 wsaddressing
18/3318
Optional Message Addressing
Properties ReplyTo
> Must be specified only when the sender expects a
response, but it can be used to route that response toany valid endpoint
FaultTo> Routes SOAP fault messages to specified endpoint
references> Always optional
From> A service consumer identify itself to the service
8/6/2019 wsaddressing
19/3319
Separation of Endpoints
Explicitly separating the message source endpoint,expected reply endpoint, and fault handlingendpoint from one another helps WS-Addressingsupport a variety of messaging models beyond thesimple request/reply interactions we typicallyassociate with web services.
8/6/2019 wsaddressing
20/33
20
Message ID
When a reply is expected, whether it is expected bythe sender or by a third endpoint specified in theReplyTo header, a MessageIdelement must alsobe present.
The message ID is a unique URI.
Because web services can be used over unreliabletransports, it is possible that an endpoint will receive
duplicate copies of a message.> The message ID can be used to avoid processing the
same message twice.
8/6/2019 wsaddressing
21/33
21
Relation Type
RelatesTo element provides a standard way toassociate incoming replies with their correspondingrequests
8/6/2019 wsaddressing
22/33
WS-AddressingWS-AddressingAnnotationsAnnotations
8/6/2019 wsaddressing
23/33
23
Annotations
@javax.xml.ws.soap.Addressing> Is used to enable addressing.> With this annotation, the generated WSDL for this
service contains in thebinding section
@Action and @FaultAction> Are used to specify explicit wsa:Action values
> Are reflected the in theportType definitions of thegenerated wsdl
Without any explicit action values, default valuesare used as per WS-Addressing specification
8/6/2019 wsaddressing
24/33
24
Example1: @Action Default Value
In the absence of the wsa:Action attribute, the followingpattern is used to construct a default action for inputsand outputs. The general form of an action URI is asfollows:> [target namespace]/[port type name]/[input|output
name]
8/6/2019 wsaddressing
25/33
25
Example1: @Action Default Value
Use default values for @Action
@javax.jws.WebServicepublic class AddNumbersImpl { @javax.ws.addressing.Action
public int addNumbers(int number1, int number2) {return number1 + number2;
}}
Generated WSDL
...
...
8/6/2019 wsaddressing
26/33
26
Example2: @Action input input attribute is specified and output attribute is derived from input
@javax.jws.WebServicepublic class AddNumbersImpl { @javax.ws.addressing.Action(input="http://example.com/numbers/add")
public int addNumbers(int number1, int number2) {return number1 + number2;
}
}
Generated WSDL
...
...
8/6/2019 wsaddressing
27/33
27
Example3: Annotations in Java Code
@Addressing@WebServicepublic class AddNumbersImpl {
@Action(input = "http://example.com/input",output = "http://example.com/output")
public int addNumbers(int number1, int number2) throws AddNumbersException {return impl(number1, number2);
}
@Action(input = "http://example.com/input3",
output = "http://example.com/output3",fault = {@FaultAction(className = AddNumbersException.class, value =
"http://example.com/fault3")}
)public int addNumbers3(int number1, int number2) throws AddNumbersException {
return impl(number1, number2);}
8/6/2019 wsaddressing
28/33
28
Example3: WSDL Document
8/6/2019 wsaddressing
29/33
29
Example: SOAP Request Message
http://localhost:4040/jaxws-fromjava-
wsaddressing/addnumbershttp://server.fromjava_wsaddressing/AddN
umbersImpl/addNumbers2Request
http://www.w3.org/2005/08/addressing/anonymousuuid:b734fc16-1cbb-4201-
a944-7d593babf0f3
1010
8/6/2019 wsaddressing
30/33
30
Example: SOAP Response Message
http://www.w3.org/2005/08/addressing/anonymous
http://server.fromjava_wsaddressing/AddNumbersImpl/addNumbers2Response
uuid:9d395f31-40a3-4c47-a396-cd68564d674f
uuid:b734fc16-1cbb-4201-a944-7d593babf0f3
20
8/6/2019 wsaddressing
31/33
WS-Addressing &WS-Addressing &Stateful Web ServiceStateful Web Service
8/6/2019 wsaddressing
32/33
32
WS-Addressing and Stateful Service
WS-Addressing also defines a standard forincluding service-specific attributes within anaddress> These attributes are particularly useful for the creation of
stateful web services, which are services that canreceive a series of requests from a particular client andremember some state information between requests.
8/6/2019 wsaddressing
33/33
Thank You!Thank You!