axis2肥皂记录

发布于 2024-10-09 11:10:56 字数 128 浏览 0 评论 0原文

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

有人可以指导我一篇文章,解释如何在 Axis2 中记录肥皂消息。

I have generated java clients uisng wsdl2java using axis2. My client programs can sucessfully connect to webservice. I want to log outgoing soap request to read soap message.

Can someone direct me to an article expaining how can I log soap messages in Axis2.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

疯到世界奔溃 2024-10-16 11:10:56

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

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

I realize this is an old question, but in case it helps anyone you can turn on logging by putting this tag into both the <requestFlow> and <responseFlow> sections of your globalConfig in your server-config.wsdd file:

<handler type="java:org.apache.axis.handlers.LogHandler"/>
我纯我任性 2024-10-16 11:10:56

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

you can additionally consider writing a custom axis module for logging - check http://axis.apache.org/axis2/java/core/docs/modules.html for more information

初熏 2024-10-16 11:10:56

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

If you're using Axis2 Data Binding, then the automatically-generated classes for your web services will all be subclasses of ADBBean. You can use something like the following to convert an ADBBean to a string, then log the string.

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;
}
浸婚纱 2024-10-16 11:10:56

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

Please see Step 6 here: Axis2 Hello world. Besides that, you may check SoapUI

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文