KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > jbi > serviceengine > util > soap > MessageExchangeHelper


1 /*
2  * MessageExchangeHelper.java
3  *
4  * Created on February 5, 2006, 9:51 AM
5  *
6  * To change this template, choose Tools | Options and locate the template under
7  * the Source Creation and Management node. Right-click the template and choose
8  * Open. You can then make changes to the template in the Source Editor.
9  */

10
11 package com.sun.enterprise.jbi.serviceengine.util.soap;
12
13 import org.w3c.dom.*;
14
15 import com.sun.enterprise.deployment.ServiceReferenceDescriptor;
16 import com.sun.enterprise.deployment.ServiceRefPortInfo;
17 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException;
18 import com.sun.enterprise.jbi.serviceengine.comm.MessageSender;
19 import com.sun.enterprise.jbi.serviceengine.core.JavaEEServiceEngineContext;
20 import com.sun.enterprise.jbi.serviceengine.core.ServiceEngineEndpoint;
21 import com.sun.enterprise.jbi.serviceengine.core.EndpointRegistry;
22 import com.sun.jbi.wsdl11wrapper.*;
23 import com.sun.logging.LogDomains;
24 import javax.jbi.messaging.*;
25 import javax.jbi.messaging.Fault;
26 import javax.jbi.servicedesc.ServiceEndpoint;
27 import javax.xml.namespace.QName JavaDoc;
28 import javax.xml.soap.SOAPBody JavaDoc;
29 import javax.xml.soap.SOAPEnvelope JavaDoc;
30 import javax.xml.soap.SOAPMessage JavaDoc;
31 import javax.xml.soap.SOAPPart JavaDoc;
32 import javax.xml.transform.*;
33 import javax.xml.transform.dom.*;
34 import javax.wsdl.*;
35 import javax.wsdl.factory.*;
36 import java.util.logging.Logger JavaDoc;
37 import java.util.logging.Level JavaDoc;
38 import java.util.concurrent.ConcurrentHashMap JavaDoc;
39
40 /**
41  * This class helps in normalizing a SOAP message and denormalizing a normalized
42  * message into a SOAP Message
43  * @author mu125243
44  */

45 public class MessageExchangeHelper {
46     
47     private static Logger JavaDoc logger =
48             LogDomains.getLogger(LogDomains.SERVER_LOGGER);
49     
50     private MessageExchange messageExchange;
51     private ServiceRefPortInfo portInfo;
52
53     // For storing the WSDL cache.
54
private static ConcurrentHashMap JavaDoc wsdlCache = new ConcurrentHashMap JavaDoc(11,0.75f,4);
55
56     private static String JavaDoc WSDL11 = "http://schemas.xmlsoap.org/wsdl/";
57
58     /** Creates a new instance of MessageExchangeHelper */
59     public MessageExchangeHelper() {
60     }
61     
62     public void setMessageExchange(MessageExchange messageExchange) {
63         this.messageExchange = messageExchange;
64     }
65     
66     
67     public SOAPMessage JavaDoc denormalizeMessage(boolean inFlag) throws ServiceEngineException {
68         validateMessageExchange();
69         NormalizedMessage normalizedMsg = null;
70         
71         if(inFlag) {
72             if(isInOutMessageExchange()) {
73                 InOut inOutExchange = (InOut)messageExchange;
74                 normalizedMsg = inOutExchange.getInMessage();
75                 
76             } else {
77                 InOnly inOnlyExchange = (InOnly)messageExchange;
78                 normalizedMsg = inOnlyExchange.getInMessage();
79             }
80         } else {
81             // assumed that it's a inout message
82
normalizedMsg = (messageExchange.getFault()!=null)?
83                     messageExchange.getFault() : ((InOut)messageExchange).getOutMessage();
84         //create inonly or inout message exchange based on the instance
85
}
86         
87         QName JavaDoc operationQName = messageExchange.getOperation();
88         String JavaDoc pattern = messageExchange.getPattern().toString();
89         
90         Operation operation = new Operation(operationQName.getLocalPart(), pattern);
91         // DeNormalize response msg to SOAP msg
92

93         MessageDenormalizerImpl d = new MessageDenormalizerImpl();
94         SOAPWrapper wrapper;
95         if(messageExchange.getFault()!=null) {
96             // Assuming soap binding does not wrap a fault message
97
wrapper = d.denormalizeFaultMessage((Fault)normalizedMsg);
98         } else {
99             unWrapMessage(normalizedMsg);
100             wrapper = d.denormalizeMessage(normalizedMsg, operation, !inFlag);
101         }
102         SOAPMessage JavaDoc message = wrapper.getMessage();
103         printSOAPMessage( "Denormalizing in ? "+ inFlag + "message :" , message) ;
104         return message;
105         
106     }
107     
108     public boolean isInOutMessageExchange() {
109         return messageExchange instanceof InOut;
110     }
111     
112     public void normalizeMessage(SOAPMessage JavaDoc soapMessage, boolean inFlag) throws ServiceEngineException {
113         validateMessageExchange();
114         if(soapMessage != null) {
115             
116             
117             printSOAPMessage( "normalizing in ? "+ inFlag + "message :" , soapMessage) ;
118             NormalizedMessage normalizedMsg = null;
119             Operation operation = null;
120             try {
121                 
122                 boolean isFault = (soapMessage.getSOAPBody().getFault() != null);
123                 normalizedMsg =
124                         (isFault)? messageExchange.createFault() : messageExchange.createMessage();
125                 
126                 //soapMessage.writeTo(System.out);
127
if(isFault) {
128                     // Assuming soap binding does not unwrap a fault message
129
SOAPWrapper wrapper = new SOAPWrapper(soapMessage);
130                     MessageNormalizerImpl normalizer = new MessageNormalizerImpl();
131                     normalizer.normalizeFaultMessage(wrapper, normalizedMsg);
132                 } else {
133                     //normalizer.normalizeMessage(wrapper, normalizedMsg, operation);
134
normalizeAndWrapMessage(normalizedMsg, soapMessage);
135                 }
136                 
137                 if(isFault)
138                     messageExchange.setFault((javax.jbi.messaging.Fault)normalizedMsg);
139                 else if(inFlag) {
140                     if(isInOutMessageExchange()) {
141                         ((InOut)messageExchange).setInMessage(normalizedMsg);
142                     } else {
143                         ((InOnly)messageExchange).setInMessage(normalizedMsg);
144                     }
145                 } else // inout assumed.
146
((InOut)messageExchange).setOutMessage(normalizedMsg);
147             } catch(Exception JavaDoc e) {
148                 e.printStackTrace();
149             }
150             
151         }
152         
153     }
154     
155     private void unWrapMessage(NormalizedMessage normalizedMsg) {
156         try {
157             String JavaDoc wsdlPath = null;
158             String JavaDoc endpointName = null;
159             QName JavaDoc serviceName = null;
160         Definition mDefinition = null;
161             EndpointMetaData emd = null;
162
163             ServiceEndpoint serviceEndpoint = messageExchange.getEndpoint();
164             if(serviceEndpoint != null) {
165                 EndpointRegistry endpointRegistry = EndpointRegistry.getInstance();
166                 endpointName = serviceEndpoint.getEndpointName();
167                 serviceName = serviceEndpoint.getServiceName();
168                 ServiceEngineEndpoint serviceEngineEndpoint = endpointRegistry.get(
169                         serviceName, endpointName);
170                 if(serviceEngineEndpoint != null)
171                     wsdlPath = serviceEngineEndpoint.getWsdlPath();
172             }
173             if(wsdlPath == null && portInfo != null) {
174                 ServiceReferenceDescriptor serviceRef = portInfo.getServiceReference();
175                 //ServiceRefPortInfo portInfo = serviceRef.getPortInfo("service.web.example.calculator.Calculator"/*sei.getName()*/);
176
serviceName = serviceRef.getServiceName();
177                 endpointName = portInfo.hasWsdlPort() ? portInfo.getWsdlPort().getLocalPart() : portInfo.getName();
178                 if(serviceRef.getWsdlFileUrl() != null && serviceRef.getWsdlFileUrl().getProtocol().equals("file"))
179                     wsdlPath = serviceRef.getWsdlFileUrl().getPath();
180                 else
181                     wsdlPath = serviceRef.getWsdlFileUri();
182             }
183
184            /*
185         * Now we have the wsdlPath here .Check to see if we already
186         * have it in our cache. If present just give it out from here
187             * else read it a fresh. Using this avoids reading the same
188         * WSDL multiple times from the same path.
189         */

190         
191         emd = (EndpointMetaData)wsdlCache.get(wsdlPath);
192         if(emd == null) {
193         if(logger.isLoggable(Level.FINEST))
194                     logger.log(Level.FINEST," Now fresh add to cache");
195                 try {
196                     mDefinition = getWsdlDefinition(wsdlPath);
197                 } catch (Exception JavaDoc e) {
198                     // This might be a 2.0 WSDL
199
logger.log(Level.WARNING, e.getMessage(), e);
200                 }
201                 emd = new EndpointMetaData(mDefinition);
202             wsdlCache.put(wsdlPath,emd);
203         if(logger.isLoggable(Level.FINEST))
204                     logger.log(Level.FINEST," Now fresh add to cache done");
205             }
206         mDefinition = emd.getDefinition();
207             if(isWsdl11(mDefinition)) {
208                 Wsdl11WrapperHelper helper = new Wsdl11WrapperHelper(mDefinition);
209                 Source source = normalizedMsg.getContent();
210                 String JavaDoc operationName = messageExchange.getOperation().getLocalPart();
211                 boolean isProvider = messageExchange.getRole().equals(MessageExchange.Role.PROVIDER);
212                 Document unwrappedDoc = helper.unwrapMessage(source,
213                                                             serviceName,
214                                                             endpointName,
215                                                             operationName,
216                                                             isProvider);
217                 normalizedMsg.setContent(new DOMSource(unwrappedDoc));
218             }
219         }catch(Exception JavaDoc e) {
220             e.printStackTrace();
221         }
222     }
223     
224     private void normalizeAndWrapMessage(NormalizedMessage normalizedMsg,
225                                          SOAPMessage JavaDoc soapMessage) {
226         try {
227             String JavaDoc wsdlPath = null;
228             String JavaDoc endpointName = null;
229             QName JavaDoc serviceName = null;
230         Definition mDefinition = null;
231             EndpointMetaData emd = null;
232             ServiceEndpoint serviceEndpoint = messageExchange.getEndpoint();
233             if(serviceEndpoint != null) {
234                 EndpointRegistry endpointRegistry = EndpointRegistry.getInstance();
235                 endpointName = serviceEndpoint.getEndpointName();
236                 serviceName = serviceEndpoint.getServiceName();
237                 ServiceEngineEndpoint serviceEngineEndpoint = endpointRegistry.get(
238                 serviceName, endpointName);
239                 if(serviceEngineEndpoint != null)
240                     wsdlPath = serviceEngineEndpoint.getWsdlPath();
241             }
242             if(wsdlPath == null && portInfo != null) {
243                 ServiceReferenceDescriptor serviceRef = portInfo.getServiceReference();
244                 //ServiceRefPortInfo portInfo = serviceRef.getPortInfo("service.web.example.calculator.Calculator"/*sei.getName()*/);
245
serviceName = serviceRef.getServiceName();
246                 endpointName = portInfo.hasWsdlPort() ? portInfo.getWsdlPort().getLocalPart() : portInfo.getName();
247                 if(serviceRef.getWsdlFileUrl() != null && serviceRef.getWsdlFileUrl().getProtocol().equals("file"))
248                     wsdlPath = serviceRef.getWsdlFileUrl().getPath();
249                 else
250                     wsdlPath = serviceRef.getWsdlFileUri();
251             }
252            /*
253             * Now we have the wsdlPath here .Check to see if we already
254             * have it in our cache. If present just give it out from here
255             * else read it a fresh. Using this avoids reading the same
256             * WSDL multiple times from the same path.
257             */

258         emd = (EndpointMetaData)wsdlCache.get(wsdlPath);
259         if(emd == null) {
260         if(logger.isLoggable(Level.FINEST))
261                     logger.log(Level.FINEST," wrap : Now fresh add to cache");
262                 mDefinition = getWsdlDefinition(wsdlPath);
263                 emd= new EndpointMetaData(mDefinition,serviceName,endpointName);
264                 emd.resolve();
265                 wsdlCache.put(wsdlPath,emd);
266         if(logger.isLoggable(Level.FINEST))
267                    logger.log(Level.FINEST,"wrap : Now fresh add to cache done");
268             }
269
270         mDefinition = emd.getDefinition();
271             Wsdl11WrapperHelper helper = new Wsdl11WrapperHelper(mDefinition);
272             if(isWsdl11(mDefinition)) {
273                 //String operationName = messageExchange.getOperation().getLocalPart();
274
String JavaDoc operationName = null;
275                 Operation operation = null;
276                 if (messageExchange.getOperation() == null) {
277                     operationName = emd.getOperationMetaData(soapMessage).getOperationName();
278             if (logger.isLoggable(Level.FINEST))
279                         logger.finest("Operation Name is :" + operationName);
280                     QName JavaDoc opQName = new QName JavaDoc(
281                                     messageExchange.getService().getNamespaceURI(),
282                                     operationName);
283                     messageExchange.setOperation(opQName);
284                     operation = getOperation(soapMessage,
285                                     serviceName, operationName);
286                 } else {
287                     operationName = messageExchange.getOperation().getLocalPart();
288                     operation = new Operation(operationName,
289                                     messageExchange.getPattern().toString());
290                 }
291
292                 SOAPWrapper wrapper = new SOAPWrapper(soapMessage);
293                 MessageNormalizerImpl normalizer = new MessageNormalizerImpl();
294                 normalizer.normalizeMessage(wrapper, normalizedMsg, operation);
295                 Document wrappedDoc = null;
296                 Source source = normalizedMsg.getContent();
297                 boolean isProvider = messageExchange.getRole().equals(MessageExchange.Role.PROVIDER);
298                 wrappedDoc = helper.wrapMessage(source, serviceName, endpointName, operationName,!isProvider);
299
300                 normalizedMsg.setContent(new DOMSource(wrappedDoc));
301              }
302         }catch(Exception JavaDoc e) {
303             e.printStackTrace();
304         }
305         
306     }
307     
308     private Definition getWsdlDefinition(String JavaDoc wsdlPath) throws Exception JavaDoc{
309         javax.wsdl.factory.WSDLFactory mFactory = WSDLFactory.newInstance();
310         javax.wsdl.xml.WSDLReader mReader = mFactory.newWSDLReader();
311         Definition mDefinition = mReader.readWSDL(wsdlPath);
312         return mDefinition;
313     }
314
315     private boolean isWsdl11(Definition mDefinition)
316     throws Wsdl11WrapperHelperException {
317        try
318        {
319            if (mDefinition != null) {
320                String JavaDoc xmlns = mDefinition.getNamespace ("");
321                if (xmlns.trim ().equals(WSDL11)) {
322                    return true;
323                }
324            }
325        }
326        catch (Exception JavaDoc e)
327        {
328            throw new Wsdl11WrapperHelperException("Cannot get version", e);
329        }
330        return false;
331     }
332
333     public MessageExchange getMessageExchange() {
334         return messageExchange;
335     }
336     
337     public void initializeMessageExchange(ServiceRefPortInfo portInfo, boolean oneWay)
338     throws ServiceEngineException {
339         try {
340             this.portInfo = portInfo;
341             QName JavaDoc svcQName = portInfo.getServiceReference().getServiceName();
342             DeliveryChannel channel =
343                     JavaEEServiceEngineContext.getInstance(). getDeliveryChannel();
344             // Create MessageExchange
345
MessageExchangeFactory factory =
346                     channel.createExchangeFactoryForService(svcQName);
347             
348             MessageExchange msgExchange = null;
349             NormalizedMessage inMsg = null;
350             
351             if(oneWay) {
352                 InOnly inMessageExchange = factory.createInOnlyExchange();
353                 inMsg = inMessageExchange.createMessage();
354                 inMessageExchange.setInMessage(inMsg);
355                 msgExchange = inMessageExchange;
356             } else {
357                 InOut inOutMessageExchange = factory.createInOutExchange();
358                 inMsg = inOutMessageExchange.createMessage();
359                 inOutMessageExchange.setInMessage(inMsg);
360                 msgExchange = inOutMessageExchange;
361             }
362             msgExchange.setService(svcQName);
363             setMessageExchange(msgExchange);
364         } catch(Exception JavaDoc e) {
365             throw new ServiceEngineException(e);
366         }
367     }
368
369     public void initializeMessageExchange(ServiceRefPortInfo portInfo, SOAPMessage JavaDoc soapMessage)
370     throws ServiceEngineException {
371         try {
372             this.portInfo = portInfo;
373             QName JavaDoc svcQName = portInfo.getServiceReference().getServiceName();
374             DeliveryChannel channel =
375                     JavaEEServiceEngineContext.getInstance(). getDeliveryChannel();
376             // Create MessageExchange
377
MessageExchangeFactory factory =
378                     channel.createExchangeFactoryForService(svcQName);
379             
380             MessageExchange msgExchange = null;
381             NormalizedMessage inMsg = null;
382             QName JavaDoc opQName = null;
383             
384             // Check if it is oneway.
385
boolean oneWay = false;
386             String JavaDoc wsdlPath = null;
387             String JavaDoc endpointName = null;
388             QName JavaDoc serviceName = null;
389         Definition mDefinition = null;
390             EndpointMetaData emd = null;
391
392             ServiceReferenceDescriptor serviceRef = portInfo.getServiceReference();
393             //ServiceRefPortInfo portInfo = serviceRef.getPortInfo("service.web.example.calculator.Calculator"/*sei.getName()*/);
394
serviceName = serviceRef.getServiceName();
395             endpointName = portInfo.hasWsdlPort() ? portInfo.getWsdlPort().getLocalPart() : portInfo.getName();
396             if(serviceRef.getWsdlFileUrl() != null && serviceRef.getWsdlFileUrl().getProtocol().equals("file"))
397                 wsdlPath = serviceRef.getWsdlFileUrl().getPath();
398             else
399                 wsdlPath = serviceRef.getWsdlFileUri();
400             
401            /*
402             * Now we have the wsdlPath here .Check to see if we already
403             * have it in our cache. If present just give it out from here
404             * else read it a fresh. Using this avoids reading the same
405             * WSDL multiple times from the same path.
406             */

407         emd = (EndpointMetaData)wsdlCache.get(wsdlPath);
408         if(emd == null) {
409         if(logger.isLoggable(Level.FINEST))
410                     logger.log(Level.FINEST," wrap : Now fresh add to cache");
411                 mDefinition = getWsdlDefinition(wsdlPath);
412                 emd= new EndpointMetaData(mDefinition,serviceName,endpointName);
413                 emd.resolve();
414                 wsdlCache.put(wsdlPath,emd);
415         if(logger.isLoggable(Level.FINEST))
416                    logger.log(Level.FINEST,"wrap : Now fresh add to cache done");
417             }
418             
419         mDefinition = emd.getDefinition();
420             Wsdl11WrapperHelper helper = new Wsdl11WrapperHelper(mDefinition);
421             if(isWsdl11(mDefinition)) {
422                 EndpointMetaData.OperationMetaData operationMetaData = emd.getOperationMetaData(soapMessage);
423                 oneWay = operationMetaData.isOneWay();
424                 String JavaDoc operationName = operationMetaData.getOperationName();
425                 opQName = new QName JavaDoc(svcQName.getNamespaceURI(), operationName);
426                 logger.log(Level.FINE, "IsOneWay(" + operationName + ") = " + oneWay);
427             }
428             // end :: check if it is oneway.
429

430             if(oneWay) {
431                 InOnly inMessageExchange = factory.createInOnlyExchange();
432                 inMsg = inMessageExchange.createMessage();
433                 inMessageExchange.setInMessage(inMsg);
434                 msgExchange = inMessageExchange;
435             } else {
436                 InOut inOutMessageExchange = factory.createInOutExchange();
437                 inMsg = inOutMessageExchange.createMessage();
438                 inOutMessageExchange.setInMessage(inMsg);
439                 msgExchange = inOutMessageExchange;
440             }
441             
442             msgExchange.setService(svcQName);
443             msgExchange.setOperation(opQName);
444             setMessageExchange(msgExchange);
445         } catch(Exception JavaDoc e) {
446             e.printStackTrace();
447             throw new ServiceEngineException(e);
448         }
449     }
450     
451     public void handleException(Exception JavaDoc exception) {
452         try {
453             if((messageExchange instanceof InOut) ||
454                (messageExchange instanceof RobustInOnly)){
455                 normalizeException(exception);
456             } else if (messageExchange instanceof InOnly) {
457                 messageExchange.setStatus(ExchangeStatus.ERROR);
458             }
459             dispatchMessage();
460         } catch(Exception JavaDoc e) {
461            logger.log(Level.SEVERE, e.getMessage());
462         }
463     }
464     
465     public void handleResponse(SOAPMessage JavaDoc response, boolean flag) {
466         try {
467             if(messageExchange instanceof InOut) {
468                 normalizeMessage(response, flag);
469             } else if((messageExchange instanceof InOnly ) ||
470                 (messageExchange instanceof RobustInOnly)) {
471                 messageExchange.setStatus(ExchangeStatus.DONE);
472             }
473             dispatchMessage();
474         } catch(Exception JavaDoc e) {
475            logger.log(Level.SEVERE, e.getMessage());
476         }
477     }
478     
479     public void normalizeException(Exception JavaDoc exception) {
480         if(exception != null) {
481             try {
482                 MessageDenormalizerImpl d = new MessageDenormalizerImpl();
483                 SOAPWrapper soapWrapper = d.denormalizeMessage(exception);
484                 normalizeMessage(soapWrapper.getMessage(), false);
485                 
486             } catch(Exception JavaDoc e) {
487                 e.printStackTrace();
488             }
489         }
490     }
491     
492     public void dispatchMessage() throws ServiceEngineException {
493         if(messageExchange != null) {
494             MessageSender messageSender = new MessageSender();
495             messageSender.setMessageExchange(messageExchange);
496             messageSender.send();
497             ServiceEngineException exception = messageSender.getException();
498             if(exception != null)
499                 throw exception;
500         }
501     }
502     
503     private void validateMessageExchange() throws ServiceEngineException {
504         if(messageExchange == null)
505             throw new ServiceEngineException("MessageExchange not set, use setMessageExchange()");
506     }
507     
508     
509     private Operation getOperation(SOAPMessage JavaDoc soapMessage, QName JavaDoc svcQName,
510         String JavaDoc opName) throws ServiceEngineException {
511         try {
512             // Get operation name from the localpart of the first child
513
// of <env:Body> in SOAP msg
514
SOAPPart JavaDoc sp = soapMessage.getSOAPPart();
515             SOAPEnvelope JavaDoc env = sp.getEnvelope();
516             SOAPBody JavaDoc body = env.getBody();
517              // first child of body is like <ns0:sayHello>
518
org.w3c.dom.Node JavaDoc firstChild = body.getFirstChild();
519             String JavaDoc namespacePrefix = firstChild.getPrefix();
520             
521             // Get WSDL operation QName. This is in the same namespace as the
522
// service, declared in the <definitions> element in the WSDL file.
523
String JavaDoc svcNamespace = svcQName.getNamespaceURI();
524             
525             // namespace URI for body content is the WSDL "types" namespace
526
// as in the <schema> element in the WSDL file.
527
String JavaDoc namespaceURI = null;
528             if(namespacePrefix != null)
529                 namespaceURI = env.getNamespaceURI(namespacePrefix);
530             else
531                 namespaceURI = svcNamespace;
532             
533             QName JavaDoc opQName = new QName JavaDoc(svcNamespace, opName);
534             
535             // Normalize Message
536
Operation operation = new Operation(opName, "in-out");
537             // TODO Does JAXRPC2.0 allow WSDL 2.0's uri or multipart styles ?
538
operation.setStyle("rpc");
539             operation.setInputNamespace(namespaceURI);
540             operation.setOutputNamespace(namespaceURI);
541             return operation;
542             
543         } catch(Exception JavaDoc e) {
544             e.printStackTrace();
545             
546             throw new ServiceEngineException(e.getMessage());
547         }
548     }
549     
550     
551     protected void printSOAPMessage(String JavaDoc message, SOAPMessage JavaDoc soapMessage) {
552         try {
553             if(logger.isLoggable(Level.FINE)) {
554                 System.out.print(message);
555                 soapMessage.writeTo(System.out);
556             }
557         }catch(Exception JavaDoc e) {
558             System.out.println(e.getMessage());
559         }
560     }
561     
562     protected void printSOAPContent(String JavaDoc message, NormalizedMessage normalizedMessage) {
563         if(logger.isLoggable(Level.FINE)) {
564             if(normalizedMessage != null) {
565                 javax.xml.transform.Source JavaDoc source = normalizedMessage.getContent() ;
566                 if(source != null) {
567                     try {
568                         javax.xml.transform.Transformer JavaDoc transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer();
569                         System.out.print(message);
570                         javax.xml.transform.stream.StreamResult JavaDoc result = new javax.xml.transform.stream.StreamResult JavaDoc(System.out);
571                         transformer.transform(source, result);
572                     } catch(Exception JavaDoc e) {
573                         e.printStackTrace();
574                     }
575                 }
576                 
577             }
578         }
579     }
580     
581 }
582
Popular Tags