如何使用JAX-WS将SOAP标头添加到SOAP请求中? [英] How to add SOAP headers to a SOAP request using JAX-WS?
问题描述
我们需要使用其他团队开发的Web服务.使用JAX-WS
生成Web服务.我们正在使用 wsimport 生成客户端存根.
We need to consume webservices developed by other team. Using JAX-WS
for generating the webservices. We are using wsimport to generate the client side stubs.
问题是我需要将以下信息作为标头与SOAP正文一起传递:
The problem is that i need to pass the following info as a header along with the SOAP body:
<soapenv:Header>
<ns1:HeaderData xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:ns1="http://www.example.com/esb/data_type/HeaderData/v1">
<ChannelIdentifier>ABC</ChannelIdentifier>
</ns1:HeaderData>
</soapenv:Header>
我们正在使用:
We are using:
BindingProvider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
serviceConfig.getServiceEndPoint()
);
设置端点.
有人可以建议如何通过请求传递标头吗?
Can anyone suggest how to pass headers with request?
谢谢, VK
推荐答案
使用@WebParam
批注
@WebMethod
@WebResult String method(
@WebParam String anotherParam
@WebParam(header = true, mode = Mode.OUT) Holder<String> headerParam)
header = true, mode = Mode.OUT
表示参数headerParam
将仅在标头中的输出中.
如果要在输入和输出中使用此参数,请创建Mode.INOUT
header = true, mode = Mode.OUT
means that param headerParam
will be only in output in header.
If you want this this param in input and in output, make Mode.INOUT
这篇关于如何使用JAX-WS将SOAP标头添加到SOAP请求中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!