Similar to the recent problem with jaxws Provider, the jaxws Dispatch doesn't
allow override of outbound ws addressing headers either. I tried setting with
the following code:
AddressingProperties wsaClient = new AddressingPropertiesImpl();
// snipped out properties setting
// attach these properties to the outbound message object
disp.getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND,
wsaClient);
The problem appears to be in the ContextUtils file again with these lines:
String mapProperty =
ContextUtils.getMAPProperty(isProviderContext,
isRequestor,
isOutbound);
LOG.log(Level.FINE,
"retrieving MAPs from context property {0}",
mapProperty);
AddressingPropertiesImpl maps =
(AddressingPropertiesImpl)message.get(mapProperty);
The first time through this method we have isProviderContext==true,
isRequestor==true, and isOutbound==true. So mapProperty gets set to
"javax.xml.ws.addressing.context" but the override data is stored in
"javax.xml.ws.addressing.context.outbound" (because of the way I called it).
This is due to the following lookup code (also in ContextUtils):
public static String getMAPProperty(boolean isRequestor,
boolean isProviderContext,
boolean isOutbound) {
return isRequestor
? isProviderContext
? CLIENT_ADDRESSING_PROPERTIES
: isOutbound
? CLIENT_ADDRESSING_PROPERTIES_OUTBOUND
: CLIENT_ADDRESSING_PROPERTIES_INBOUND
: isOutbound
? SERVER_ADDRESSING_PROPERTIES_OUTBOUND
: SERVER_ADDRESSING_PROPERTIES_INBOUND;
}
In this case isRequest and isProviderContext are true, so we end up with
CLIENT_ADDRESSING_PROPERTIES instead of CLIENT_ADDRESSING_PROPERTIES_OUTBOUND.
Perhaps the problem is my understanding as this will work fine if I change my
code to:
disp.getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES,
wsaClient);
It just seems inconsistent to me to override the server side addressing
properties by setting JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND but
then for the client to have CLIENT_ADDRESSING_PROPERTIES_OUTBOUND be wrong and
instead require CLIENT_ADDRESSING_PROPERTIES. Am I just misunderstanding, or
is this actually implemented wrong? If it's wrong, is the fix to change
getMAPProperty to:
return isRequestor
? isOutbound
? CLIENT_ADDRESSING_PROPERTIES_OUTBOUND
: isProviderContext
? CLIENT_ADDRESSING_PROPERTIES
: CLIENT_ADDRESSING_PROPERTIES_INBOUND
: isOutbound
? SERVER_ADDRESSING_PROPERTIES_OUTBOUND
: SERVER_ADDRESSING_PROPERTIES_INBOUND;
Or will that break something else?
Thanks,
Jesse