01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.dispatchers;
21:
22: import org.apache.axiom.om.OMElement;
23: import org.apache.axiom.om.OMNamespace;
24: import org.apache.axis2.AxisFault;
25: import org.apache.axis2.context.MessageContext;
26: import org.apache.axis2.description.AxisService;
27: import org.apache.axis2.description.HandlerDescription;
28: import org.apache.axis2.engine.AxisConfiguration;
29: import org.apache.axis2.util.LoggingControl;
30: import org.apache.axis2.util.Utils;
31: import org.apache.commons.logging.Log;
32: import org.apache.commons.logging.LogFactory;
33:
34: public class SOAPMessageBodyBasedServiceDispatcher extends
35: AbstractServiceDispatcher {
36:
37: public static final String NAME = "SOAPMessageBodyBasedServiceDispatcher";
38: private static final Log log = LogFactory
39: .getLog(SOAPMessageBodyBasedServiceDispatcher.class);
40:
41: public AxisService findService(MessageContext messageContext)
42: throws AxisFault {
43: String serviceName = null;
44: OMElement bodyFirstChild = messageContext.getEnvelope()
45: .getBody().getFirstElement();
46:
47: if (bodyFirstChild != null) {
48: OMNamespace ns = bodyFirstChild.getNamespace();
49:
50: if (ns != null) {
51: String filePart = ns.getNamespaceURI();
52:
53: if (LoggingControl.debugLoggingAllowed
54: && log.isDebugEnabled()) {
55: log
56: .debug(messageContext.getLogIDString()
57: + "Checking for Service using SOAP message body's first child's namespace : "
58: + filePart);
59: }
60: String[] values = Utils
61: .parseRequestURLForServiceAndOperation(
62: filePart, messageContext
63: .getConfigurationContext()
64: .getServiceContextPath());
65:
66: if (values[0] != null) {
67: serviceName = values[0];
68:
69: AxisConfiguration registry = messageContext
70: .getConfigurationContext()
71: .getAxisConfiguration();
72:
73: return registry.getService(serviceName);
74: }
75: }
76: }
77:
78: return null;
79: }
80:
81: public void initDispatcher() {
82: init(new HandlerDescription(NAME));
83: }
84: }
|