这是在不使用WebSphere内置JAX-WS实现读取整个消息的情况下访问标头的方法。
public boolean handleMessage(SOAPMessageContext context) { AttributedURI messageIdURI = (AttributedURI)context.get("com.ibm.wsspi.wsaddressing.inbound.MessageID"); String messageId = ""; if (messageIdURI != null && messageIdURI.getURI() != null) { messageId = messageIdURI.getURI().toString(); } EndpointReference fromApplicationEPR = (EndpointReference)context.get("com.ibm.wsspi.wsaddressing.inbound.FromEPR"); String fromApplication = ""; if (fromApplicationEPR != null && fromApplicationEPR.getAddress() != null && fromApplicationEPR.getAddress().getURI() != null) { fromApplication = fromApplicationEPR.getAddress().getURI().toString(); } ... return true;}
注意,这取决于精确的JAX-WS实现。如果有机会,我将通过Apache CXF发布如何执行此 *** 作。这是上述代码所需的导入:
import com.ibm.ws.wsaddressing.AttributedURI;import com.ibm.ws.wsaddressing.EndpointReference;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)