2

我有一个部署了 Web 服务的 JBoss AS。对该 Web 服务的调用会产生对另一个 JBoss AS 中另一个 Web 服务的调用。我有兴趣在 SOAP 消息的标头中传递一些参数,因此当 SOAP 消息到达第一个 JBoss AS 时,我会读取标头参数,对它们执行一些操作,并将它们放入定向到的消息的标头第二个 JBoss AS。我正在使用两个 SOAPHandler,并在我使用的第一个 AS 中将参数传递给 Web 服务:

public boolean handleMessage(SOAPMessageContext context) { 
... 
//get the parameter from the header
...
context.put("parameter", parameter);
context.setScope("parameter", MessageContext.Scope.APPLICATION);
}

这样我就可以在 Web 服务中执行以下操作:

parameter = wsContext.getMessageContext().get("parameter").toString();
...
((BindingProvider) service).getRequestContext().put("parameter", parameter);

在第二个 SOAPHandler 中,管理定向到第二个 AS 的消息:

public boolean handleMessage(SOAPMessageContext context) { 
...
parameter = (String) context.get("parameter");
...
//put the parameter in the header
}

这行得通,但是如果新消息到达第一个 AS 时没有参数,则之前的消息仍保留在上下文中,而我将旧参数发送到第二个 AS。也许这与:MessageContext.Scope.APPLICATION

4

0 回答 0