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.
/** * @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: Peter Maas [mailto:[EMAIL PROTECTED] Sent: Friday, April 08, 2005 6:23 AM To: Venkat Reddy Cc: axis-user@ws.apache.org Subject: Re: How to dump the raw SOAP Envelope? Why don't you trace the soap message on TCP level using a tool like ngrep or ethereal? On Fri, 2005-04-08 at 16:05 +0530, Venkat Reddy wrote: > You can write a tiny logging handler to do something like - > > Transformer transformer = > TransformerFactory.newInstance().newTransformer(); > StringWriter stringWriter = new StringWriter(128); > transformer.transform(new DOMSource(env), new > StreamResult(stringWriter)); StringBuffer buffer = > stringWriter.getBuffer(); > > - venkat > > On Apr 8, 2005 3:55 PM, Jin-Ha Tchoe <[EMAIL PROTECTED]> wrote: > > Hi, > > > > we use Axis 1.2 Alpha with Tomcat 4.0.3 and Castor 0.95 for a > > SOAP-Service. Sometimes we have customers you are not accustomed to > > SOAP and have lots of problems using our Service. The problems range > > from simple typos and wrong namespaces to forgetting the SOAP-Envelope. > > > > Whenever Axis and Castor are unable to determine the right Service > > or (Un-)marshal the message, the most the customers can see (and > > therefore > > us) is a simple AxisFault. Unfortunately that does not help us see > > what exactly is going wrong. So, is there a way for Axis to dump the > > complete raw SOAP Envelope _before_ doing its work, so that we can something? > > > > Many thanks in advance, > > > > Jin-Ha Tchoe > > -- > > Jin-Ha Tchoe <[EMAIL PROTECTED]> > > > > > > -- Peter Maas Application Architect / Streaming Noterik Multimedia BV Prins Hendrikkade 120 1011 AM Amsterdam The Netherlands Tel: +31 (0)205929966 Fax: +31 (0)204688405 Gsm: +31 (0)616096324 Web: www.noterik.nl -------------------------------------- Take a look at our streaming solutions: http://www.streamedit.com/demo.html Get firefox: http://www.mozilla.org/products/firefox/ --------------------------------------- :wq!