001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.geronimo.axis.builder;
018
019 import java.util.Iterator;
020 import java.util.List;
021 import javax.wsdl.BindingOperation;
022 import javax.wsdl.Operation;
023 import javax.wsdl.Message;
024 import javax.wsdl.BindingInput;
025 import javax.wsdl.extensions.soap.SOAPOperation;
026 import javax.wsdl.extensions.soap.SOAPBody;
027 import javax.wsdl.extensions.ExtensibilityElement;
028 import javax.xml.namespace.QName;
029
030 import org.apache.geronimo.axis.client.OperationInfo;
031 import org.apache.geronimo.common.DeploymentException;
032 import org.apache.geronimo.webservices.builder.SchemaInfoBuilder;
033 import org.apache.axis.soap.SOAPConstants;
034 import org.apache.axis.description.OperationDesc;
035
036 public abstract class OperationDescBuilder {
037 protected final OperationDesc operationDesc;
038 protected final BindingOperation bindingOperation;
039 protected final Operation operation;
040 protected final String operationName;
041 protected final Message input;
042 protected final Message output;
043 protected final SOAPOperation soapOperation;
044 protected boolean built;
045
046 public OperationDescBuilder(BindingOperation bindingOperation) throws DeploymentException {
047 this.bindingOperation = bindingOperation;
048 this.operation = bindingOperation.getOperation();
049 this.soapOperation = (SOAPOperation) SchemaInfoBuilder.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
050
051 operationDesc = new OperationDesc();
052 output = operation.getOutput() == null ? null : operation.getOutput().getMessage();
053 operationName = operation.getName();
054 input = operation.getInput().getMessage();
055 }
056
057 public abstract OperationInfo buildOperationInfo(SOAPConstants soapVersion) throws DeploymentException;
058
059 public abstract OperationDesc buildOperationDesc() throws DeploymentException;
060
061 protected QName getOperationNameFromSOAPBody() {
062 BindingInput bindingInput = bindingOperation.getBindingInput();
063 List extensibilityElements = bindingInput.getExtensibilityElements();
064 for (Iterator iterator = extensibilityElements.iterator(); iterator.hasNext();) {
065 ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next();
066 if (extensibilityElement instanceof SOAPBody) {
067 String namespaceURI = ((SOAPBody)extensibilityElement).getNamespaceURI();
068 return new QName(namespaceURI, operationName);
069 }
070 }
071 return new QName("", operationName);
072 }
073 }