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