KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > transport > http > HTTPTransport


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.transport.http;
18
19 import org.apache.axis.AxisEngine;
20 import org.apache.axis.AxisFault;
21 import org.apache.axis.MessageContext;
22 import org.apache.axis.client.Call;
23 import org.apache.axis.client.Transport;
24
25 /**
26  * Extends Transport by implementing the setupMessageContext function to
27  * set HTTP-specific message context fields and transport chains.
28  * May not even be necessary if we arrange things differently somehow.
29  * Can hold state relating to URL properties.
30  *
31  * @author Rob Jellinghaus (robj@unrealities.com)
32  * @author Doug Davis (dug@us.ibm.com)
33  * @author Glen Daniels (gdaniels@allaire.com)
34  */

35 public class HTTPTransport extends Transport
36 {
37     public static final String JavaDoc DEFAULT_TRANSPORT_NAME = "http";
38     
39     /**
40      * HTTP properties
41      */

42     public static final String JavaDoc URL = MessageContext.TRANS_URL;
43
44     private Object JavaDoc cookie;
45     private Object JavaDoc cookie2;
46     private String JavaDoc action;
47     
48     public HTTPTransport () {
49         transportName = DEFAULT_TRANSPORT_NAME;
50     }
51     
52     /**
53      * helper constructor
54      */

55     public HTTPTransport (String JavaDoc url, String JavaDoc action)
56     {
57         transportName = DEFAULT_TRANSPORT_NAME;
58         this.url = url;
59         this.action = action;
60     }
61     
62     /**
63      * Set up any transport-specific derived properties in the message context.
64      * @param mc the context to set up
65      * @param call the call (unused?)
66      * @param engine the engine containing the registries
67      * @throws AxisFault if service cannot be found
68      */

69     public void setupMessageContextImpl(MessageContext mc,
70                                         Call call,
71                                         AxisEngine engine)
72         throws AxisFault
73     {
74         if (action != null) {
75             mc.setUseSOAPAction(true);
76             mc.setSOAPActionURI(action);
77         }
78
79         // Set up any cookies we know about
80
if (cookie != null)
81             mc.setProperty(HTTPConstants.HEADER_COOKIE, cookie);
82         if (cookie2 != null)
83             mc.setProperty(HTTPConstants.HEADER_COOKIE2, cookie2);
84
85         // Allow the SOAPAction to determine the service, if the service
86
// (a) has not already been determined, and (b) if a service matching
87
// the soap action has been deployed.
88
if (mc.getService() == null) {
89             mc.setTargetService( (String JavaDoc)mc.getSOAPActionURI() );
90         }
91     }
92
93     public void processReturnedMessageContext(MessageContext context) {
94         cookie = context.getProperty(HTTPConstants.HEADER_COOKIE);
95         cookie2 = context.getProperty(HTTPConstants.HEADER_COOKIE2);
96     }
97 }
98
Popular Tags