有人可以告诉我如何捕获在客户端和服务器Web服务应用程序之间传递的SOAP消息。Web服务SOAP消息监视或日志记录
我试过使用这两种工具。 口袋肥皂 http://www.pocketsoap.com/pocketsoap/
提琴手 http://www.fiddlertool.com/fiddler/
我可能会错过一些设置,它不是为我工作。
帮助将更受赞赏。
有人可以告诉我如何捕获在客户端和服务器Web服务应用程序之间传递的SOAP消息。Web服务SOAP消息监视或日志记录
我试过使用这两种工具。 口袋肥皂 http://www.pocketsoap.com/pocketsoap/
提琴手 http://www.fiddlertool.com/fiddler/
我可能会错过一些设置,它不是为我工作。
帮助将更受赞赏。
这里我的代码在C++中用于在发送之前使用Soap Toolkit 3.0检索xml消息。
.
.
.
Serializer->EndEnvelope();
/* ___________________ */
char * bufferxml = NULL;
_variant_t punt = _variant_t((IUnknown*)Serializer);
punt.lVal += 48;
_variant_t punt1 = *punt.ppunkVal;
punt1.lVal += 32;
_variant_t punt2 = *punt1.ppunkVal;
punt2.lVal += 4;
memcpy(&bufferxml, (char *) *punt2.ppunkVal, sizeof(char *));
punt2.lVal += 4;
int lengxml = *(punt2.pintVal);
bufferxml[lengxml] = '\0';
/* ___________________ */
// Send the message to the web service
Connector->EndMessage();
.
.
.
punt.Detach();
punt1.Detach();
punt2.Detach();
punt.Clear();
punt1.Clear();
punt2.Clear();
Serializer.Release();
.
.
.
我希望真的能帮到你,这是我的设计,它对我有用。
如果您有兴趣,您可以编写一个Java扩展GenericSOAPHandler类的处理程序,并将输出打印到任何你喜欢的地方。在这个(简单的)情况下,服务器日志:
@SuppressWarnings("rawtypes")
public class MyHandler extends GenericSOAPHandler {
private void print(InputStream input, OutputStream out) throws Exception {
try {
DocumentBuilder parser;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
parser = factory.newDocumentBuilder();
Document document = parser.parse(input);
Transformer serializer = TransformerFactory.newInstance().newTransformer();
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
serializer.transform(new DOMSource(document), new StreamResult(out));
} catch (TransformerException e) {
// A fatal error occurred
throw new Exception(e);
}
}
@Override
protected boolean handleInbound(MessageContext msgContext) {
SOAPMessageContext soapMessageCtx = (SOAPMessageContext) msgContext;
SOAPMessage soapMessage = soapMessageCtx.getMessage();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
soapMessage.writeTo(outputStream);
byte[] array = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(array);
System.out.println("SOAP request message:\n");
print(inputStream, System.out);
} catch (SOAPException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
@Override
protected boolean handleOutbound(MessageContext msgContext) {
SOAPMessageContext soapMessageCtx = (SOAPMessageContext) msgContext;
SOAPMessage soapMessage = soapMessageCtx.getMessage();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
soapMessage.writeTo(outputStream);
byte[] array = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(array);
System.out.println("SOAP response message:\n");
print(inputStream, System.out);
} catch (SOAPException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
}
您还需要确保您的处理程序包含在你的服务器上执行的JAXWS-处理-server.xml中:
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
<handler-chain>
<protocol-bindings>##SOAP11_HTTP</protocol-bindings>
<handler>
<handler-name>DebugHandler</handler-name>
<handler-class>handlers.MyHandler</handler-class>
</handler>
</handler-chain>
</handler-chains>
有也是TCP/IP监视器,它与用于eclipse的WTP插件捆绑在一起,允许您在端口上设置监视器来查看SOAP请求。
Thanks @Rich,我一直在寻找这样的解决方案。你救了我的命。现在我可以看到我的肥皂请求在输出,而不是监测端口等。 为了使用这个你将需要下载并添加这个罐子: 下载链接:http://www.java2s.com/Code/Jar/j/Downloadjbosswsapi100Beta1jar热媒 – AdrianES 2014-05-14 09:32:26