从客户端读取Axis2输出(Stub)

时间:2014-03-27 16:33:36

标签: axis2

我正在获得toEnvelope方法的价值。当我尝试阅读axisclient(WS client)时 得到null值。

System.out.println("toEnvelope :"+param.getOTA_VehCancelRSSequence_type0().getVehCancelRSCore().getUniqueID().getID());
org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope();

请帮我解决这个问题

1 个答案:

答案 0 :(得分:0)

您可以使用客户端的getLastOperationContext()方法获取最后一个OperationContext

对于外发邮件:

OperationContext operationContext = stub._getServiceClient().getLastOperationContext();
if (operationContext != null) {

    MessageContext outMsgContext = operationContext.getMessageContext("Out");
    if (outMsgContext != null) {
        System.out.println("Out SOAP Message : "+outMsgContext.getEnvelope().toString());
    }       

}

对于收到的消息:

OperationContext operationContext = stub._getServiceClient().getLastOperationContext();
if (operationContext != null) {

    MessageContext inMsgContext = operationContext.getMessageContext("In");
    if (inMsgContext != null) {
        System.out.println("Received SOAP Message: "+ inMsgContext.getEnvelope().toString());
    }

}