我已经使用axis2生成了使用wsdl2java的java客户端。我的客户端程序可以成功地连接到webservice。我想记录读取soap消息的传出soap请求。
有人可以将我引向一篇解释如何在Axis2中记录soap消息的文章吗?
发布于 2011-06-18 01:24:31
我知道这是一个古老的问题,但如果它对任何人有帮助,您可以通过将此标记放入服务器的globalConfig -config.wsdd文件中的<requestFlow>和<responseFlow>部分来打开日志:
<handler type="java:org.apache.axis.handlers.LogHandler"/>发布于 2011-08-04 04:39:43
您还可以考虑编写一个用于日志记录的自定义axis模块-有关详细信息,请查看http://axis.apache.org/axis2/java/core/docs/modules.html
发布于 2011-05-12 05:32:25
如果您正在使用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;
}https://stackoverflow.com/questions/4548334
复制相似问题