Source code: org/apache/axis/handlers/http/HTTPActionHandler.java
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.handlers.http;
18
19 import org.apache.axis.AxisFault;
20 import org.apache.axis.MessageContext;
21 import org.apache.axis.components.logger.LogFactory;
22 import org.apache.axis.handlers.BasicHandler;
23 import org.apache.axis.utils.Messages;
24 import org.apache.commons.logging.Log;
25
26
27 /** An <code>HTTPActionHandler</code> simply sets the context's TargetService
28 * property from the HTTPAction property. We expect there to be a
29 * Router on the chain after us, to dispatch to the service named in
30 * the SOAPAction.
31 *
32 * In the real world, this might do some more complex mapping of
33 * SOAPAction to a TargetService.
34 *
35 * @author Glen Daniels (gdaniels@allaire.com)
36 * @author Doug Davis (dug@us.ibm.com)
37 */
38 public class HTTPActionHandler extends BasicHandler
39 {
40 protected static Log log =
41 LogFactory.getLog(HTTPActionHandler.class.getName());
42
43 public void invoke(MessageContext msgContext) throws AxisFault
44 {
45 log.debug("Enter: HTTPActionHandler::invoke");
46
47 /** If there's already a targetService then just return.
48 */
49 if ( msgContext.getService() == null ) {
50 String action = (String) msgContext.getSOAPActionURI();
51 log.debug( " HTTP SOAPAction: " + action );
52
53 /** The idea is that this handler only goes in the chain IF this
54 * service does a mapping between SOAPAction and target. Therefore
55 * if we get here with no action, we're in trouble.
56 */
57 if (action == null) {
58 throw new AxisFault( "Server.NoHTTPSOAPAction",
59 Messages.getMessage("noSOAPAction00"),
60 null, null );
61 }
62
63 action = action.trim();
64
65 // handle empty SOAPAction
66 if (action.length() > 0 && action.charAt(0) == '\"') {
67 // assertTrue(action.endsWith("\"")
68 if (action.equals("\"\"")) {
69 action = "";
70 } else {
71 action = action.substring(1, action.length() - 1);
72 }
73 }
74
75 // if action is zero-length string, don't set anything
76 if (action.length() > 0) {
77 msgContext.setTargetService( action );
78 }
79 }
80
81 log.debug("Exit: HTTPActionHandler::invoke");
82 }
83 }