KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > soap > ConnectionIDRequestHandler


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote.soap;
10
11 import org.apache.axis.AxisFault;
12 import org.apache.axis.Message;
13 import org.apache.axis.MessageContext;
14 import org.apache.axis.encoding.XMLType;
15 import org.apache.axis.handlers.BasicHandler;
16 import org.apache.axis.message.SOAPEnvelope;
17 import org.apache.axis.message.SOAPHeaderElement;
18
19 /**
20  * This class is used in the Axis deployment descriptor, and parses the SOAP header
21  * (on server-side) that contains the connection ID sent by the client.
22  *
23  * @version $Revision: 1.5 $
24  */

25 public class ConnectionIDRequestHandler extends BasicHandler
26 {
27    public void invoke(MessageContext context) throws AxisFault
28    {
29       Message message = context.getRequestMessage();
30       SOAPEnvelope envelope = message.getSOAPEnvelope();
31       SOAPHeaderElement header = envelope.getHeaderByName(SOAPConstants.NAMESPACE_URI, SOAPConstants.CONNECTION_ID_HEADER_NAME);
32       if (header == null) throw new AxisFault("Could not find mandatory header " + SOAPConstants.CONNECTION_ID_HEADER_NAME);
33
34       try
35       {
36          String JavaDoc id = (String JavaDoc)header.getValueAsType(XMLType.XSD_STRING);
37          if (id != null && id.length() > 0) context.setProperty(SOAPConstants.CONNECTION_ID_HEADER_NAME, id);
38       }
39       catch (Exception JavaDoc x)
40       {
41          throw AxisFault.makeFault(x);
42       }
43       finally
44       {
45          header.setProcessed(true);
46       }
47    }
48 }
49
Popular Tags