java web服务客户端,添加http头

问题描述:

在wsdl上使用wsimport创建了一个java Web服务客户端,我需要为http请求中嵌入的每个soap消息设置Authorization标头。生成了javax.xml.ws.Service的子类后,如何将http标头附加到每个传出请求???

Having created a java web service client using wsimport on a wsdl, I need to set the Authorization header for each soap message embedded in an http request. Having generated a subclass of javax.xml.ws.Service, how can I append an http header to each outgoing request???

您可以将带有自定义标题的地图传递给BindingProvider(我相信您可以设置MessageContext.HTTP_REQUEST_HEADERS属性)。尝试创建一个Authorization标头并将其传入。

You can pass a map with custom headers to the BindingProvider (I believe you can set the MessageContext.HTTP_REQUEST_HEADERS property). Try creating an Authorization header and passing it in.