KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > remote > soap > LZSOAPHandler


1 /* *****************************************************************************
2  * LZSOAPHandler.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.remote.soap;
11
12 import java.util.*;
13 import javax.xml.namespace.QName JavaDoc;
14 import javax.xml.rpc.handler.*;
15 import javax.xml.rpc.handler.soap.*;
16 import javax.xml.soap.*;
17 import org.apache.log4j.*;
18
19 public class LZSOAPHandler extends GenericHandler
20 {
21     private static Logger mLogger = Logger.getLogger(LZSOAPHandler.class);
22
23     public QName JavaDoc[] getHeaders() {
24         return null;
25     }
26
27     public boolean handleRequest(MessageContext context) {
28         if (mLogger.isDebugEnabled()) {
29             mLogger.debug("========== handleRequest(" + context + ") ");
30             displaySOAPMessage(context);
31             mLogger.debug("==========");
32         }
33         return true;
34     }
35
36     public boolean handleResponse(MessageContext context) {
37         if (mLogger.isDebugEnabled()) {
38             mLogger.debug("========== handleResponse(" + context + ") ");
39 // displaySOAPMessage(context);
40
mLogger.debug("==========");
41         }
42         return true;
43     }
44
45     public void displaySOAPMessage(MessageContext context) {
46         try {
47             SOAPMessageContext soapContext = (SOAPMessageContext)context;
48
49             SOAPMessage message = soapContext.getMessage();
50             SOAPPart sp = message.getSOAPPart();
51             SOAPEnvelope envelope = sp.getEnvelope();
52             SOAPBody body = envelope.getBody();
53             SOAPHeader header = envelope.getHeader();
54
55             mLogger.debug(envelope.getClass().getName() + '@' + Integer.toHexString(envelope.hashCode()));
56             mLogger.debug(envelope);
57
58         } catch (Exception JavaDoc e) {
59             e.printStackTrace();
60         }
61     }
62 }
63
Popular Tags