axis2肥皂记录

时间:2010-12-28 18:22:24

标签: logging axis2

我使用axis2生成了java客户端uisng wsdl2java。我的客户端程序可以成功连接到webservice。我想记录外发肥皂请求以阅读肥皂消息。

有人可以引导我阅读一篇文章,了解如何在Axis2中记录soap消息。

4 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:2)

您还可以考虑编写自定义轴模块进行记录 - 检查http://axis.apache.org/axis2/java/core/docs/modules.html以获取更多信息

答案 2 :(得分:1)

如果您正在使用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;
}

答案 3 :(得分:0)

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