简体   繁体   English

如何在axis2 Web服务中读取SOAP原始请求和响应消息

[英]How to read the SOAP raw rquest and response messages in axis2 webservices

I am using the axis2 web-service client and I want to capture the request and response raw xml. 我正在使用axis2 Web服务客户端,并且想要捕获请求和响应原始xml。 I have created a LogHandler to read the response raw xml, but I don't know how to configure this LogHandler file in an axis2 webservice. 我创建了一个LogHandler来读取响应原始xml,但是我不知道如何在axis2 Web服务中配置此LogHandler文件。 Could you please help me how to configure this LogHandler or tell me if there is any way to get the request and response xml's. 您能否帮助我如何配置此LogHandler或告诉我是否有任何方法可以获取请求和响应xml。

import org.apache.axis2.AxisFault;`enter code here`
import org.apache.axis2.context.MessageContext;`enter code here`
import org.apache.axis2.engine.Handler;`enter code here`
import org.apache.axis2.handlers.AbstractHandler;`enter code here`
import org.apache.axis2.description.AxisService;`enter code here`
import org.apache.log4j.Logger;`enter code here`
public class LogHandler extends AbstractHandler implements Handler {
    private static Logger logger = Logger.getLogger(LogHandler.class);

    private String name;

    public LogHandler() {
        System.out.println(" & from LogHandler &&& constructor :");
    }
    public String getName() {
        System.out
                .println("LogHandler.getName() LogHandlerLogHandlerLogHandlerLogHandlerLogHandler");
        return name;
    }
    public InvocationResponse invoke(MessageContext msgContext)
            throws AxisFault {
        logger.info("***" + msgContext.getEnvelope().toString());
        System.out.println("LogHandler.invoke()"
                + msgContext.getEnvelope().toString());
        AxisService axService = msgContext.getAxisService();
        logger.info("*Service******" + axService.toString());
        System.out.println("*axService******" + axService.toString());

        return InvocationResponse.CONTINUE;
    }
    public void revoke(MessageContext msgContext) {
        System.out.println("& LogHandler.revoke()");
    }
    public void setName(String name) {
        System.out.println("LogHandler " + name);
        this.name = name;
    }
}

You can have your custom phase defined and add your handler there and see your handler get executed or not. 您可以定义自定义阶段,然后在其中添加处理程序,然后查看处理程序是否执行。 //i have added below configuration in axis2.xml but the service is not running.//Seems somewhere your message flow is broken. ///我在axis2.xml中添加了以下配置,但是该服务未运行。//似乎您的消息流中断了。

Check this flowing guide. 检查此流动指南。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM