1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.apache.geronimo.axis.builder;
19
20 import java.util.Iterator;
21 import java.util.List;
22 import javax.wsdl.BindingOperation;
23 import javax.wsdl.Operation;
24 import javax.wsdl.Message;
25 import javax.wsdl.BindingInput;
26 import javax.wsdl.extensions.soap.SOAPOperation;
27 import javax.wsdl.extensions.soap.SOAPBody;
28 import javax.wsdl.extensions.ExtensibilityElement;
29 import javax.xml.namespace.QName;
30
31 import org.apache.geronimo.axis.client.OperationInfo;
32 import org.apache.geronimo.common.DeploymentException;
33 import org.apache.geronimo.webservices.builder.SchemaInfoBuilder;
34 import org.apache.axis.soap.SOAPConstants;
35 import org.apache.axis.description.OperationDesc;
36
37 public abstract class OperationDescBuilder {
38 protected final OperationDesc operationDesc;
39 protected final BindingOperation bindingOperation;
40 protected final Operation operation;
41 protected final String operationName;
42 protected final Message input;
43 protected final Message output;
44 protected final SOAPOperation soapOperation;
45 protected boolean built;
46
47 public OperationDescBuilder(BindingOperation bindingOperation) throws DeploymentException {
48 this.bindingOperation = bindingOperation;
49 this.operation = bindingOperation.getOperation();
50 this.soapOperation = (SOAPOperation) SchemaInfoBuilder.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
51
52 operationDesc = new OperationDesc();
53 output = operation.getOutput() == null ? null : operation.getOutput().getMessage();
54 operationName = operation.getName();
55 input = operation.getInput().getMessage();
56 }
57
58 public abstract OperationInfo buildOperationInfo(SOAPConstants soapVersion) throws DeploymentException;
59
60 public abstract OperationDesc buildOperationDesc() throws DeploymentException;
61
62 protected QName getOperationNameFromSOAPBody() {
63 BindingInput bindingInput = bindingOperation.getBindingInput();
64 List extensibilityElements = bindingInput.getExtensibilityElements();
65 for (Iterator iterator = extensibilityElements.iterator(); iterator.hasNext();) {
66 ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next();
67 if (extensibilityElement instanceof SOAPBody) {
68 String namespaceURI = ((SOAPBody)extensibilityElement).getNamespaceURI();
69 return new QName(namespaceURI, operationName);
70 }
71 }
72 return new QName("", operationName);
73 }
74 }