001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.binding.soap.model;
019:
020: import org.apache.cxf.binding.soap.Soap11;
021: import org.apache.cxf.binding.soap.Soap12;
022: import org.apache.cxf.binding.soap.SoapVersion;
023: import org.apache.cxf.service.model.BindingInfo;
024: import org.apache.cxf.service.model.BindingOperationInfo;
025: import org.apache.cxf.service.model.OperationInfo;
026: import org.apache.cxf.service.model.ServiceInfo;
027:
028: import org.apache.cxf.wsdl.WSDLConstants;
029:
030: public class SoapBindingInfo extends BindingInfo {
031: private SoapVersion soapVersion;
032:
033: private String style;
034:
035: private String transportURI;
036:
037: public SoapBindingInfo(ServiceInfo serv, String n) {
038: this (serv, n, null);
039: resolveSoapVersion(n);
040: }
041:
042: public SoapBindingInfo(ServiceInfo serv, String n,
043: SoapVersion soapVersion) {
044: super (serv, n);
045:
046: this .soapVersion = soapVersion;
047: }
048:
049: private void resolveSoapVersion(String n) {
050: if (WSDLConstants.SOAP11_NAMESPACE.equalsIgnoreCase(n)) {
051: this .soapVersion = Soap11.getInstance();
052: } else if (WSDLConstants.SOAP12_NAMESPACE.equalsIgnoreCase(n)) {
053: this .soapVersion = Soap12.getInstance();
054: } else {
055: throw new RuntimeException("Unknow bindingId: " + n
056: + ". Can not resolve the SOAP version");
057: }
058: }
059:
060: public SoapVersion getSoapVersion() {
061: if (soapVersion == null) {
062: resolveSoapVersion(getBindingId());
063: }
064: return soapVersion;
065: }
066:
067: public void setSoapVersion(SoapVersion soapVersion) {
068: this .soapVersion = soapVersion;
069: }
070:
071: public String getStyle() {
072: return style;
073: }
074:
075: public String getStyle(OperationInfo operation) {
076: SoapOperationInfo opInfo = getOperation(operation.getName())
077: .getExtensor(SoapOperationInfo.class);
078: if (opInfo != null) {
079: return opInfo.getStyle();
080: } else {
081: return style;
082: }
083: }
084:
085: public OperationInfo getOperationByAction(String action) {
086: for (BindingOperationInfo b : getOperations()) {
087: SoapOperationInfo opInfo = b
088: .getExtensor(SoapOperationInfo.class);
089:
090: if (opInfo.getAction().equals(action)) {
091: return b.getOperationInfo();
092: }
093: }
094:
095: return null;
096: }
097:
098: /**
099: * Get the soap action for an operation. Will never return null.
100: *
101: * @param operation
102: * @return
103: */
104: public String getSoapAction(OperationInfo operation) {
105: BindingOperationInfo b = (BindingOperationInfo) getOperation(operation
106: .getName());
107: SoapOperationInfo opInfo = b
108: .getExtensor(SoapOperationInfo.class);
109:
110: if (opInfo != null && opInfo.getAction() != null) {
111: return opInfo.getAction();
112: }
113:
114: return "";
115: }
116:
117: public void setStyle(String style) {
118: this .style = style;
119: }
120:
121: public String getTransportURI() {
122: return transportURI;
123: }
124:
125: public void setTransportURI(String transportURI) {
126: this.transportURI = transportURI;
127: }
128:
129: }
|