[英]JAX-WS - Adding SOAP Headers in JBoss
I would like to set/get SOAP Headers (specifically wsa:ReplyTo
and wsa:MessageId
) in my Asynchronouse Webservice running on JBoss. 我想在JBoss上运行的异步Web服务中设置/获取SOAP标头(特别是wsa:ReplyTo
和wsa:MessageId
)。
Since, this is a JBoss platform, I cannot use com.sun.xml.ws.developer.WSBindingProvider
(as recommended in JAX-WS - Adding SOAP Headers ). 因为这是一个JBoss平台,所以我不能使用com.sun.xml.ws.developer.WSBindingProvider
(按照JAX-WS-Adding SOAP Headers中的建议 )。
One option would be to use SOAPHandler
. 一种选择是使用SOAPHandler
。 Is there any other way similar to the WSBindingProvider
solution? 还有其他类似于WSBindingProvider
解决方案的方法吗?
Unfortunately, you will need to use a specific handler for this. 不幸的是,您将需要为此使用特定的处理程序。 Previous versions of JBOSS EAP did support the javax.xml.ws.addressing
packages however it looks like these packages are not a part of EE6. 以前的JBOSS EAP版本确实支持javax.xml.ws.addressing
软件包,但是看起来这些软件包不是EE6的一部分。
Define the handler eg jaxws-handlers.xml
as: 将处理程序(例如jaxws-handlers.xml
定义为:
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_3.xsd">
<handler-chain>
<protocol-bindings>##SOAP11_HTTP</protocol-bindings>
<handler>
<handler-name>Application Server Handler</handler-name>
<handler-class>com.handler.ServerHandler</handler-class>
</handler>
</handler-chain>
Add @HandlerChain
into the Service class definition: 将@HandlerChain
添加到Service类定义中:
@WebService (...)
@HandlerChain(file="jaxws-handlers.xml")
public class TestServiceImpl implements TestService {
public String sayHello(String name) {
return "Hello " + name + "!";
}
}
And implement the Handler itself as : 并将Handler本身实现为:
public class ServerHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public boolean handleMessage(final SOAPMessageContext context) {
final Boolean outbound = (Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if ((outbound != null) && !outbound) {
//...
}
return true;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.