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: package org.apache.axis2.jaxws.client;
20:
21: import org.apache.axis2.jaxws.BindingProvider;
22: import org.apache.axis2.jaxws.core.MessageContext;
23: import org.apache.axis2.jaxws.description.OperationDescription;
24: import org.apache.commons.logging.Log;
25: import org.apache.commons.logging.LogFactory;
26:
27: public class ClientUtils {
28:
29: private static Log log = LogFactory.getLog(ClientUtils.class);
30:
31: /**
32: * Determines what the SOAPAction value should be for a given MessageContext.
33: *
34: * @param ctx - The MessageContext for the request
35: * @return A string with the calculated SOAPAction
36: */
37: public static String findSOAPAction(MessageContext ctx) {
38: OperationDescription op = ctx.getOperationDescription();
39: Boolean useSoapAction = (Boolean) ctx
40: .getProperty(BindingProvider.SOAPACTION_USE_PROPERTY);
41: if (useSoapAction != null && useSoapAction.booleanValue()) {
42: // If SOAPAction use hasn't been disabled by the client, then first
43: // look in the context properties.
44: String action = (String) ctx
45: .getProperty(BindingProvider.SOAPACTION_URI_PROPERTY);
46: if (action != null) {
47: if (log.isDebugEnabled()) {
48: log
49: .debug("Setting soap action from JAX-WS request context. Action ["
50: + action + "]");
51: }
52: return action;
53: }
54:
55: // If we didn't find anything in the context props, then we need to
56: // check the OperationDescrition to see if one was configured in the WSDL.
57: if (op != null) {
58: action = op.getAction();
59: if (action != null) {
60: if (log.isDebugEnabled()) {
61: log
62: .debug("Setting soap action from operation description. Action ["
63: + action + "]");
64: }
65: return action;
66: }
67: } else {
68: if (log.isDebugEnabled()) {
69: log
70: .debug("Cannot set the soap action. No operation description was found.");
71: }
72: }
73: } else {
74: if (log.isDebugEnabled()) {
75: log.debug("Soap action usage was disabled");
76: }
77: }
78:
79: return null;
80: }
81:
82: }
|