0
# Addressing Support
1
2
WS-Addressing implementation supporting both W3C and Member Submission specifications for message addressing, correlation, and endpoint reference management. Provides comprehensive addressing capabilities for enterprise web service communication.
3
4
## Capabilities
5
6
### Addressing Version Support
7
8
Core addressing version abstractions supporting multiple WS-Addressing specifications.
9
10
```java { .api }
11
/**
12
* WS-Addressing version enumeration with specification support
13
*/
14
package com.sun.xml.ws.api.addressing;
15
public enum AddressingVersion {
16
/** W3C WS-Addressing specification */
17
W3C("http://www.w3.org/2005/08/addressing", "wsa", "http://www.w3.org/2005/08/addressing/wsdl"),
18
19
/** Member Submission WS-Addressing specification */
20
MEMBER("http://schemas.xmlsoap.org/ws/2004/08/addressing", "wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
21
22
/** Get namespace URI for this addressing version */
23
public String getNsUri();
24
25
/** Get default namespace prefix */
26
public String getPrefix();
27
28
/** Get WSDL extension namespace */
29
public String getWsdlNsUri();
30
31
/** Get WSDL extension attribute for addressing requirement */
32
public QName getWsdlExtensionAttribute();
33
34
/** Get Action header QName */
35
public QName getActionTag();
36
37
/** Get To header QName */
38
public QName getToTag();
39
40
/** Get From header QName */
41
public QName getFromTag();
42
43
/** Get ReplyTo header QName */
44
public QName getReplyToTag();
45
46
/** Get FaultTo header QName */
47
public QName getFaultToTag();
48
49
/** Get MessageID header QName */
50
public QName getMessageIDTag();
51
52
/** Get RelatesTo header QName */
53
public QName getRelatesToTag();
54
55
/** Check if given namespace URI matches this version */
56
public boolean isNsUri(String nsUri);
57
}
58
```
59
60
### Endpoint Reference Management
61
62
Endpoint reference abstraction with support for both addressing specifications.
63
64
```java { .api }
65
/**
66
* WS-Addressing endpoint reference implementation
67
*/
68
public final class WSEndpointReference {
69
/** Create endpoint reference from Source */
70
public WSEndpointReference(Source eprInfoset, AddressingVersion version);
71
72
/** Create from JAX-WS EndpointReference */
73
public WSEndpointReference(EndpointReference epr, AddressingVersion version);
74
75
/** Create with address only */
76
public WSEndpointReference(String address, AddressingVersion version);
77
78
/** Get endpoint reference as Source */
79
public Source asSource(String rootTagName);
80
81
/** Convert to JAX-WS EndpointReference */
82
public <T extends EndpointReference> T asEndpointReference(Class<T> clazz);
83
84
/** Create new endpoint reference with different address */
85
public WSEndpointReference createWithAddress(String address);
86
87
/** Get endpoint address */
88
public String getAddress();
89
90
/** Get addressing version */
91
public AddressingVersion getVersion();
92
93
/** Get reference parameters */
94
public Header[] getReferenceParameters();
95
96
/** Get metadata */
97
public List<Element> getMetadata();
98
99
/** Check if endpoint reference has metadata */
100
public boolean hasMetadata();
101
102
/** Create addressing headers for message */
103
public void addReferenceParametersToList(HeaderList headers);
104
}
105
```
106
107
### Addressing Headers
108
109
Header creation and management for WS-Addressing message headers.
110
111
```java { .api }
112
/**
113
* Factory for creating WS-Addressing headers
114
*/
115
public final class AddressingUtils {
116
/** Create Action header */
117
public static Header createActionHeader(AddressingVersion version, String action);
118
119
/** Create To header */
120
public static Header createToHeader(AddressingVersion version, String to);
121
122
/** Create From header */
123
public static Header createFromHeader(AddressingVersion version, WSEndpointReference from);
124
125
/** Create ReplyTo header */
126
public static Header createReplyToHeader(AddressingVersion version, WSEndpointReference replyTo);
127
128
/** Create FaultTo header */
129
public static Header createFaultToHeader(AddressingVersion version, WSEndpointReference faultTo);
130
131
/** Create MessageID header */
132
public static Header createMessageIDHeader(AddressingVersion version, String messageId);
133
134
/** Create RelatesTo header */
135
public static Header createRelatesToHeader(AddressingVersion version, String relatesTo, String relationshipType);
136
137
/** Get anonymous address for version */
138
public static String getAnonymousAddress(AddressingVersion version);
139
140
/** Get none address for version */
141
public static String getNoneAddress(AddressingVersion version);
142
143
/** Check if address is anonymous */
144
public static boolean isAnonymous(AddressingVersion version, String address);
145
146
/** Check if address is none */
147
public static boolean isNone(AddressingVersion version, String address);
148
}
149
```
150
151
### One-Way Message Support
152
153
Support for one-way messaging patterns with addressing.
154
155
```java { .api }
156
/**
157
* Feature for one-way message support with addressing
158
*/
159
public final class OneWayFeature extends WebServiceFeature {
160
/** Feature ID constant */
161
public static final String ID = "http://java.sun.com/xml/ns/jaxws/addressing/oneway";
162
163
/** Default constructor enabling one-way support */
164
public OneWayFeature();
165
166
/** Constructor with enable/disable flag */
167
public OneWayFeature(boolean enabled);
168
169
/** Constructor with ReplyTo address */
170
public OneWayFeature(boolean enabled, WSEndpointReference replyTo);
171
172
/** Get ReplyTo endpoint reference */
173
public WSEndpointReference getReplyTo();
174
175
/** Get feature ID */
176
public String getID();
177
}
178
```
179
180
### Addressing Tubes
181
182
Pipeline tubes for processing WS-Addressing headers on client and server sides.
183
184
```java { .api }
185
/**
186
* Server-side WS-Addressing processing tube
187
*/
188
package com.sun.xml.ws.addressing;
189
public final class WsaServerTube extends AbstractFilterTubeImpl {
190
/** Create server addressing tube */
191
public WsaServerTube(WSEndpoint<?> endpoint, WSDLPort wsdlPort, WSBinding binding, Tube next);
192
193
/** Process request with addressing headers */
194
public NextAction processRequest(Packet request);
195
196
/** Process response with addressing headers */
197
public NextAction processResponse(Packet response);
198
199
/** Get addressing version */
200
public AddressingVersion getAddressingVersion();
201
202
/** Check if addressing is required */
203
public boolean isAddressingRequired();
204
}
205
206
/**
207
* Client-side WS-Addressing processing tube
208
*/
209
public final class WsaClientTube extends AbstractFilterTubeImpl {
210
/** Create client addressing tube */
211
public WsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next);
212
213
/** Process outbound request */
214
public NextAction processRequest(Packet request);
215
216
/** Process inbound response */
217
public NextAction processResponse(Packet response);
218
219
/** Get addressing version */
220
public AddressingVersion getAddressingVersion();
221
}
222
```
223
224
### Member Submission Support
225
226
Specific support for Member Submission WS-Addressing specification.
227
228
```java { .api }
229
/**
230
* Member Submission addressing constants
231
*/
232
package com.sun.xml.ws.addressing.v200408;
233
public final class MemberSubmissionAddressingConstants {
234
/** Member Submission namespace URI */
235
public static final String WSA_NAMESPACE_NAME = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
236
237
/** Anonymous address URI */
238
public static final String WSA_ANONYMOUS_ADDRESS = WSA_NAMESPACE_NAME + "/role/anonymous";
239
240
/** Action header name */
241
public static final QName WSA_ACTION_NAME = new QName(WSA_NAMESPACE_NAME, "Action");
242
243
/** To header name */
244
public static final QName WSA_TO_NAME = new QName(WSA_NAMESPACE_NAME, "To");
245
246
/** From header name */
247
public static final QName WSA_FROM_NAME = new QName(WSA_NAMESPACE_NAME, "From");
248
249
/** ReplyTo header name */
250
public static final QName WSA_REPLYTO_NAME = new QName(WSA_NAMESPACE_NAME, "ReplyTo");
251
252
/** FaultTo header name */
253
public static final QName WSA_FAULTTO_NAME = new QName(WSA_NAMESPACE_NAME, "FaultTo");
254
255
/** MessageID header name */
256
public static final QName WSA_MESSAGEID_NAME = new QName(WSA_NAMESPACE_NAME, "MessageID");
257
258
/** RelatesTo header name */
259
public static final QName WSA_RELATESTO_NAME = new QName(WSA_NAMESPACE_NAME, "RelatesTo");
260
}
261
262
/**
263
* Member Submission server-side addressing tube
264
*/
265
public final class MemberSubmissionWsaServerTube extends AbstractFilterTubeImpl {
266
/** Create MS server addressing tube */
267
public MemberSubmissionWsaServerTube(WSEndpoint<?> endpoint, WSDLPort wsdlPort, WSBinding binding, Tube next);
268
269
/** Process request with MS addressing */
270
public NextAction processRequest(Packet request);
271
272
/** Process response with MS addressing */
273
public NextAction processResponse(Packet response);
274
}
275
276
/**
277
* Member Submission client-side addressing tube
278
*/
279
public final class MemberSubmissionWsaClientTube extends AbstractFilterTubeImpl {
280
/** Create MS client addressing tube */
281
public MemberSubmissionWsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next);
282
283
/** Process outbound request */
284
public NextAction processRequest(Packet request);
285
286
/** Process inbound response */
287
public NextAction processResponse(Packet response);
288
}
289
```
290
291
### Policy Integration
292
293
Integration between WS-Addressing and WS-Policy for declarative configuration.
294
295
```java { .api }
296
/**
297
* Policy-based addressing feature configurator
298
*/
299
package com.sun.xml.ws.addressing.policy;
300
public final class AddressingFeatureConfigurator implements PolicyFeatureConfigurator {
301
/** Get supported policy assertions */
302
public Collection<QName> getSupportedAssertions();
303
304
/** Configure addressing features from policy */
305
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException;
306
}
307
308
/**
309
* Addressing policy validator
310
*/
311
public final class AddressingPolicyValidator implements PolicyAssertionValidator {
312
/** Validate client-side addressing policy */
313
public Fitness validateClientSide(PolicyAssertion assertion);
314
315
/** Validate server-side addressing policy */
316
public Fitness validateServerSide(PolicyAssertion assertion);
317
318
/** Get supported domains */
319
public String[] declareSupportedDomains();
320
}
321
```
322
323
### Addressing Utilities
324
325
Utility methods for working with addressing headers and endpoint references.
326
327
```java { .api }
328
/**
329
* Utility methods for endpoint reference operations
330
*/
331
public final class EndpointReferenceUtil {
332
/** Create endpoint reference from WSDL port */
333
public static WSEndpointReference getEndpointReference(WSDLPort wsdlPort, AddressingVersion version, String address);
334
335
/** Transform endpoint reference */
336
public static WSEndpointReference transform(Class<? extends EndpointReference> clazz, WSEndpointReference epr);
337
338
/** Get address from endpoint reference Source */
339
public static String getAddress(Source eprInfoset, AddressingVersion version);
340
341
/** Extract reference parameters */
342
public static List<Element> getReferenceParameters(Source eprInfoset, AddressingVersion version);
343
344
/** Create endpoint reference Source */
345
public static Source createEndpointReferenceSource(String address, QName serviceName, QName portName,
346
List<Element> referenceParameters, String wsdlAddress,
347
AddressingVersion version);
348
}
349
```
350
351
**Usage Examples:**
352
353
```java
354
import com.sun.xml.ws.api.addressing.*;
355
import com.sun.xml.ws.addressing.*;
356
import com.sun.xml.ws.addressing.v200408.*;
357
358
// Create endpoint reference
359
String serviceAddress = "http://example.com/service";
360
WSEndpointReference epr = new WSEndpointReference(serviceAddress, AddressingVersion.W3C);
361
362
// Create endpoint reference with metadata
363
QName serviceName = new QName("http://example.com/", "MyService");
364
QName portName = new QName("http://example.com/", "MyPort");
365
List<Element> referenceParameters = new ArrayList<>();
366
367
Source eprSource = EndpointReferenceUtil.createEndpointReferenceSource(
368
serviceAddress, serviceName, portName, referenceParameters,
369
"http://example.com/service?wsdl", AddressingVersion.W3C);
370
WSEndpointReference customEpr = new WSEndpointReference(eprSource, AddressingVersion.W3C);
371
372
// Create addressing headers
373
Header actionHeader = AddressingUtils.createActionHeader(AddressingVersion.W3C, "http://example.com/ProcessData");
374
Header toHeader = AddressingUtils.createToHeader(AddressingVersion.W3C, serviceAddress);
375
Header messageIdHeader = AddressingUtils.createMessageIDHeader(AddressingVersion.W3C, UUID.randomUUID().toString());
376
377
// Create ReplyTo header with endpoint reference
378
WSEndpointReference replyToEpr = new WSEndpointReference("http://client.example.com/callback", AddressingVersion.W3C);
379
Header replyToHeader = AddressingUtils.createReplyToHeader(AddressingVersion.W3C, replyToEpr);
380
381
// Add headers to message
382
HeaderList headers = new HeaderList();
383
headers.add(actionHeader);
384
headers.add(toHeader);
385
headers.add(messageIdHeader);
386
headers.add(replyToHeader);
387
388
// Service with addressing enabled
389
@WebService
390
@Addressing(enabled = true, required = true)
391
public class AddressingEnabledService {
392
@WebMethod
393
public String processData(@WebParam(name = "data") String data, @Resource WebServiceContext context) {
394
// Access addressing headers
395
MessageContext msgContext = context.getMessageContext();
396
HeaderList inboundHeaders = (HeaderList) msgContext.get(JAXWSProperties.INBOUND_HEADER_LIST_PROPERTY);
397
398
// Get Action header
399
Header actionHeader = inboundHeaders.get(AddressingVersion.W3C.getActionTag(), false);
400
if (actionHeader != null) {
401
String action = actionHeader.getStringContent();
402
System.out.println("Action: " + action);
403
}
404
405
// Get MessageID for correlation
406
Header messageIdHeader = inboundHeaders.get(AddressingVersion.W3C.getMessageIDTag(), false);
407
if (messageIdHeader != null) {
408
String messageId = messageIdHeader.getStringContent();
409
// Use messageId for response correlation
410
}
411
412
return "Processed: " + data;
413
}
414
}
415
416
// Client with addressing
417
MyService service = new MyService();
418
MyServiceInterface port = service.getMyServicePort(new AddressingFeature(true, true));
419
420
// Set ReplyTo for asynchronous response
421
WSBindingProvider wsBP = (WSBindingProvider) port;
422
WSEndpointReference callbackEpr = new WSEndpointReference("http://client.example.com/callback", AddressingVersion.W3C);
423
424
// Create custom headers for request
425
Header replyToHeader = AddressingUtils.createReplyToHeader(AddressingVersion.W3C, callbackEpr);
426
wsBP.setOutboundHeaders(replyToHeader);
427
428
// Make service call
429
String result = port.processData("test data");
430
431
// Member Submission addressing usage
432
@WebService
433
@MemberSubmissionAddressing(enabled = true, required = true)
434
public class MSAddressingService {
435
@WebMethod
436
public void processOneWay(@WebParam(name = "data") String data, @Resource WebServiceContext context) {
437
// Process one-way message with MS addressing
438
MessageContext msgContext = context.getMessageContext();
439
HeaderList headers = (HeaderList) msgContext.get(JAXWSProperties.INBOUND_HEADER_LIST_PROPERTY);
440
441
// Get MS addressing headers
442
Header actionHeader = headers.get(MemberSubmissionAddressingConstants.WSA_ACTION_NAME, false);
443
if (actionHeader != null) {
444
String action = actionHeader.getStringContent();
445
System.out.println("MS Action: " + action);
446
}
447
}
448
}
449
450
// One-way feature usage
451
WSEndpointReference replyTo = new WSEndpointReference("http://client.example.com/callback", AddressingVersion.W3C);
452
OneWayFeature oneWayFeature = new OneWayFeature(true, replyTo);
453
454
MyServiceInterface port = service.getMyServicePort(
455
new AddressingFeature(true, true),
456
oneWayFeature
457
);
458
459
// Custom addressing tube
460
public class CustomAddressingTube extends AbstractFilterTubeImpl {
461
private AddressingVersion addressingVersion;
462
463
public CustomAddressingTube(AddressingVersion version, Tube next) {
464
super(next);
465
this.addressingVersion = version;
466
}
467
468
public NextAction processRequest(Packet request) {
469
// Add custom addressing logic
470
Message message = request.getMessage();
471
HeaderList headers = message.getHeaders();
472
473
// Add custom correlation ID
474
String correlationId = generateCorrelationId();
475
Header correlationHeader = Headers.create(
476
new QName("http://example.com/correlation", "CorrelationID"),
477
correlationId);
478
headers.add(correlationHeader);
479
480
return doInvoke(next, request);
481
}
482
483
public NextAction processResponse(Packet response) {
484
// Process response addressing headers
485
return doReturnWith(response);
486
}
487
}
488
489
// Policy-based addressing configuration
490
// WS-Policy assertion in WSDL would automatically enable addressing
491
/*
492
<wsp:Policy>
493
<wsam:Addressing>
494
<wsp:Policy>
495
<wsam:Required/>
496
</wsp:Policy>
497
</wsam:Addressing>
498
</wsp:Policy>
499
*/
500
501
// The AddressingFeatureConfigurator automatically processes this policy
502
// and enables AddressingFeature with required=true
503
```