从JAX-WS异步Web服务获取HTTP响应代码 [英] Get HTTP response code from JAX-WS asynchronous web service
问题描述
我有一个异步JAX-WS Web服务(@WebService
和@WebMethod
批注).我正在用Java调用它.而且我想知道如何使用Java代码从该服务获取HTTP响应代码.
I have an asynchronous JAX-WS web service (@WebService
and @WebMethod
annotations). I am invoking it in Java. and I would like to know how to get HTTP response code from that service in Java code.
推荐答案
我在该主题上找不到任何内容,但是我根据请求上下文的构建方式推导出了解决方案,因为我需要响应上下文,因此我认为它们可能相似.请求上下文:
I couldn't find anything on that subject, but I deduced solution based on how my request context is built, because I needed response context so I thought they may be similar. Request context:
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint)
所以我认为这可能有效:
So I thought that this may work:
int responseCode = (int)((BindingProvider) port).getResponseContext().get(MessageContext.HTTP_RESPONSE_CODE);
它有效. ; )
这篇关于从JAX-WS异步Web服务获取HTTP响应代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!