What is the difference between RequestContext and MessageContext in JAX-WS?
问题:
回答1:
MessageContext provides access to the current inbound or outbound message in a JAX-WS call, specifically for JAX-WS handlers. Inbound to a service provider is the request message while outbound is the response; For a JAX-WS client handler, outbound is the request and inbound is the response.
I had to look up RequestContext - it isn't technically a JAX-WS class. It's a proprietary (read: implementation) class in the JAX-WS reference implementation. I don't think you'd want to couple/compile your code against this, but I do expect you'd see it during debugger sessions if you're using the JAX-WS RI.
If by chance you're referring to BindingProvider.getRequestContext(), this is a Map<String, Object>
that is a map that contains values for initializing the outbound request message for a JAX-WS client. For example, to programmatically set the endpoint URL:
Map<String, Object> requestContext = ((BindingProvider)port).getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, myCustomEndpointUrl);