Difference between RequestContext and MessageConte

2019-08-12 22:37发布

What is the difference between RequestContext and MessageContext in JAX-WS?

标签: soap jax-ws
1条回答
孤傲高冷的网名
2楼-- · 2019-08-12 22:46

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);
查看更多
登录 后发表回答