【问题标题】:axis2 soap loggingaxis2 肥皂日志记录
【发布时间】:2011-08-05 02:54:04
【问题描述】:

我已经使用axis2 生成了java 客户端uisng wsdl2java。我的客户端程序可以成功连接到 web 服务。我想记录传出的肥皂请求以阅读肥皂消息。

谁能指导我看一篇文章,解释如何在 Axis2 中记录肥皂消息。

【问题讨论】:

  • 有人知道如何使用axis2存根在客户端记录请求-响应SOAP吗?

标签: logging axis2


【解决方案1】:

我意识到这是一个老问题,但如果它对任何人有帮助,您可以通过将此标签放入 server-config.wsdd 文件中 globalConfig 的 <requestFlow><responseFlow> 部分来打开日志记录:

<handler type="java:org.apache.axis.handlers.LogHandler"/>

【讨论】:

  • 这与 Axis 1.x 相关,但问题是关于 Axis2。
【解决方案2】:

您还可以考虑编写用于记录的自定义轴模块 - 请查看 http://axis.apache.org/axis2/java/core/docs/modules.html 了解更多信息

【讨论】:

    【解决方案3】:

    如果您使用的是 Axis2 数据绑定,那么为您的 Web 服务自动生成的类都将是 ADBBean 的子类。您可以使用以下内容将 ADBBean 转换为字符串,然后记录该字符串。

    public static String
    writeADBBean(ADBBean aBean) throws XMLStreamException {
        if (null == aBean)
            return "null";
        OMElement omElement;
        try
        {
            // The preferred way of serializing objects generated by Axis2's
            // WSDL2JAVA involves methods that are named the same on every
            // class but that aren't inherited from any base class. So, use
            // reflection to find them.
            QName qname;
            try {
                Field qnameField = aBean.getClass().getField("MY_QNAME");
                qname = (QName)qnameField.get(aBean);
            } catch (Exception e) {
                // Some Axis2-generated objects don't have QNames. Supply
                // one based on the object's class.
                qname = new QName(aBean.getClass().getCanonicalName());
            }
            Method getOMElement = aBean.getClass().getMethod("getOMElement", QName.class, OMFactory.class);
            omElement = (OMElement)getOMElement.invoke(aBean, qname, OMAbstractFactory.getOMFactory());
        } catch (Exception e) {
            log.warn("Reflection failed for " + aBean.toString() + ": " + e.toString());
            throw new XMLStreamException("Cannot serialize " + aBean.toString(), e);
        } catch (NoClassDefFoundError e) {
            log.error("NoClassDefFoundError while serializing " + aBean.toString() + ": " + e.toString());
            throw new XMLStreamException("Cannot serialize " + aBean.toString(), e);
        }
        String serialized = omElement.toStringWithConsume();
        return serialized;
    }
    

    【讨论】:

      【解决方案4】:

      请参阅此处的第 6 步:Axis2 Hello world。除此之外,您可以查看SoapUI

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多