Here is the methods I wrote to marshal SOAPMessages. This would provide output similar to what you see in TCPMon. I have modified it to take any object and add it as <element ...>..</element> in the SOAP. Email me if you need any specific details about it
/** * @param object passed to create SOAPMessage */ public static String marshal(Object msg) { if (msg == null) return null; RPCElement rpcElement = new RPCElement("soapmessage"); // Structure of a SOAP Envelope is // SOAPEnvelope // --> RPCElement // ---> RPCParam * n // Create RPCParam of each ISMessage param. // Serialize. Encapuslate it with RPCElement // that contains the dummy method name. Set // RPCElement as body in SOAPEnvelope String paramName = "param" Class cl = param.getClass(); Object value = param; QName xmlTypeQName = getTypeQName(cl); // AxisEngine provides implementation of this. I have not shown it here. If you need it email me. ParameterDesc paramDesc = new ParameterDesc(); paramDesc.setQName(new QName("", paramName)); paramDesc.setTypeQName(xmlTypeQName); paramDesc.setJavaType(cl); RPCParam rpcParam = new RPCParam(paramName, value); rpcParam.setParamDesc(paramDesc); rpcElement.addParam(rpcParam); SOAPEnvelope message = new SOAPEnvelope(); message.addBodyElement(rpcElement); StringBuffer sb = new StringBuffer(); String retStr = null; try { // This is Axis Specific code to serialize SOAPEnvelope // MessageContext is used through out AxisEngine which // is used as scratchpad by different modules of Axis. // Hence it is important tha twe set the SOAPEnvelope in // message context MessageContext mc = new MessageContext(aa.getAxisEngine()); Message soapMsg = new Message(message); mc.setMessage(soapMsg); // We need to add content type header as it is used during // deserialization to unmarshal any attachements present. // Content header will specify the multipart mime header contents // along with boundry tags. sb.append(HTTPConstants.HEADER_CONTENT_TYPE).append(": "); long contentLength = soapMsg.getContentLength(); if (log.isDebugEnabled()) log.debug(" ContentLength " + contentLength); // This Call does all the magic of analyzing soap message and // any attachements to form the header String contentType = soapMsg.getContentType(mc.getSOAPConstants()); sb.append(contentType); sb.append("\r\n"); // Required CR for Content Header ByteArrayOutputStream bos = new ByteArrayOutputStream(); soapMsg.writeTo(bos); // Serialize the actual soap message along with attachments sb.append(bos.toString()); retStr = sb.toString(); // Combine content header with body and we are done if (log.isDebugEnabled()) log.debug(" Marshalled Msg is \n" + retStr); } catch (Exception e) { log.error(" Exception occured while dumping ISMessage ", e); } return retStr; } -Suresh -----Original Message----- From: Ralph Pöllath [mailto:[EMAIL PROTECTED] Sent: Friday, April 08, 2005 11:40 AM To: axis-user@ws.apache.org Subject: Logging all requests Hi, I'm using code generated by wsdl2java in my spring based app and would like to log the SOAP envelopes of all outgoing requests and their responses - basically what tcpmon does, but without running a separate process. Any ideas? Cheers, -Ralph.