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.binding;
20:
21: import javax.xml.ws.Binding;
22:
23: import org.apache.axis2.jaxws.description.EndpointDescription;
24:
25: public class BindingUtils {
26:
27: /**
28: * Creates a Binding instance based on an EndpointDescription.
29: * @param ed
30: * @return
31: */
32: public static Binding createBinding(EndpointDescription ed) {
33: if (ed == null) {
34: // Do we default to the SOAPBinding?
35: }
36:
37: String bindingType = (ed.getServiceDescription().isServerSide()) ? ed
38: .getBindingType()
39: : ed.getClientBindingID();
40:
41: if (BindingUtils.isSOAPBinding(bindingType)) {
42: return new SOAPBinding(ed);
43: } else if (BindingUtils.isHTTPBinding(bindingType)) {
44: return new HTTPBinding(ed);
45: } else {
46: // If we can't figure it out, let's default to
47: // a SOAPBinding
48: return new SOAPBinding(ed);
49: }
50: }
51:
52: public static boolean isSOAPBinding(String url) {
53: if (url != null
54: && (url.equals(SOAPBinding.SOAP11HTTP_BINDING)
55: || url
56: .equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
57: || url.equals(SOAPBinding.SOAP12HTTP_BINDING) || url
58: .equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING))) {
59: return true;
60: }
61: return false;
62: }
63:
64: public static boolean isHTTPBinding(String url) {
65: if (url != null && url.equals(HTTPBinding.HTTP_BINDING)) {
66: return true;
67: }
68: return false;
69: }
70: }
|