Webservice SOAP Message Monitoring or Logging

Can someone tell me how to capture SOAP messages passed between client and server webservice applications.

I have tried using both tools. pocket soap http://www.pocketsoap.com/pocketsoap/

Violinist http://www.fiddlertool.com/fiddler/

I may be missing some settings, it doesn't work for me.

help would be more appreciated.

+1


source to share


4 answers


Try tcpmon .

soapUI integrates with tcpmon and can provide you with a more user-friendly interface.



See also ; You can also try the MV Visual Roundtrip Analyzer Analyzer.

+5


source


if you're curious, you can write a handler in Java that extends the GenericSOAPHandler class and prints the output wherever you like. In this (simple) case, the server log is:

@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;
    }

}

      



You also need to make sure your handler is included in the jaxws-handlers-server.xml of your server implementation:

<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>

      

+4


source


Here's my code in C ++ to fetch the xml message using Soap Toolkit 3.0 before submitting.

.
.
.
   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();
.
.
.

      

Hope it really helps you, this is my design and it worked for me.

+1


source


There is also a TCP / IP monitor that comes bundled with the eclipse WTP plugin that allows you to configure the monitor to a port to view SOAP requests.

0


source







All Articles