1 23 24 29 30 package com.sun.enterprise.webservice.monitoring; 31 32 import java.util.Date ; 33 import java.util.logging.Level ; 34 import java.io.ByteArrayOutputStream ; 35 36 import java.util.regex.Matcher ; 37 import java.util.regex.Pattern ; 38 39 46 public class MessageTraceImpl implements MessageTrace { 47 48 private Endpoint source; 49 private String soapMessage=null; 50 private TransportInfo transportInfo=null; 51 private int hashcode=0; 52 53 54 55 public MessageTraceImpl() { 56 57 } 58 59 64 public String getMessage(boolean includeHeaders) { 65 66 if (soapMessage!=null) { 67 if (includeHeaders) { 68 return soapMessage; 69 } 70 71 StringBuffer sb = new StringBuffer (); 72 Pattern p = Pattern.compile("<env:Body>.*</env:Body>"); 73 Matcher m = p.matcher(soapMessage); 74 if (m.find()) { 75 return soapMessage.substring(m.start(),m.end()); 76 } else { 77 return soapMessage; 78 } 79 } 80 return null; 81 } 82 83 86 public Endpoint getEndpoint() { 87 return source; 88 } 89 90 public void setMessageContext(com.sun.xml.rpc.spi.runtime.SOAPMessageContext soapMessageCtx) { 91 92 hashcode = soapMessageCtx.hashCode(); 93 94 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 95 try { 96 soapMessageCtx.getMessage().writeTo(baos); 97 } catch(Exception e) { 98 WebServiceEngineImpl.sLogger.log(Level.WARNING, "Cannot log SOAP Message " + e.getMessage()); 99 } 100 101 soapMessage = baos.toString(); 102 } 103 104 public void setMessageContext(com.sun.xml.ws.spi.runtime.SOAPMessageContext soapMessageCtx) { 105 106 hashcode = soapMessageCtx.hashCode(); 107 108 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 109 try { 110 soapMessageCtx.getMessage().writeTo(baos); 111 } catch(Exception e) { 112 WebServiceEngineImpl.sLogger.log(Level.WARNING, "Cannot log SOAP Message " + e.getMessage()); 113 } 114 115 soapMessage = baos.toString(); 116 } 117 118 public String getMessageID() { 119 return String.valueOf(hashcode); 120 } 121 122 public void setEndpoint(Endpoint source) { 123 this.source = source; 124 } 125 126 public TransportInfo getTransportInfo() { 127 return transportInfo; 128 } 129 130 public void setTransportInfo(TransportInfo info) { 131 transportInfo = info; 132 } 133 } 134 | Popular Tags |