1 17 package org.apache.geronimo.axis.builder; 18 19 import java.lang.reflect.Method ; 20 import java.util.List ; 21 import java.util.Iterator ; 22 23 import javax.xml.namespace.QName ; 24 import javax.wsdl.Part; 25 import javax.wsdl.BindingOperation; 26 27 import org.apache.geronimo.axis.client.OperationInfo; 28 import org.apache.geronimo.common.DeploymentException; 29 import org.apache.axis.soap.SOAPConstants; 30 import org.apache.axis.description.OperationDesc; 31 import org.apache.axis.description.ParameterDesc; 32 import org.apache.axis.constants.Style; 33 import org.apache.axis.constants.Use; 34 import org.objectweb.asm.Type; 35 36 39 public class LightweightOperationDescBuilder extends OperationDescBuilder { 40 41 private final Method method; 42 43 public LightweightOperationDescBuilder(BindingOperation bindingOperation, Method method) throws DeploymentException{ 44 super(bindingOperation); 45 if (bindingOperation == null) { 46 throw new DeploymentException("No BindingOperation supplied for method " + method.getName()); 47 } 48 49 this.method = method; 50 51 operationDesc.setName(operationName); 52 operationDesc.setStyle(Style.RPC); 53 operationDesc.setUse(Use.ENCODED); 54 } 55 56 public OperationInfo buildOperationInfo(SOAPConstants soapVersion) throws DeploymentException { 57 buildOperationDesc(); 58 String soapActionURI = soapOperation.getSoapActionURI(); 59 boolean usesSOAPAction = (soapActionURI != null); 60 QName operationQName = getOperationNameFromSOAPBody(); 61 62 String methodName = method.getName(); 63 String methodDesc = Type.getMethodDescriptor(method); 64 65 66 OperationInfo operationInfo = new OperationInfo(operationDesc, usesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, methodDesc); 67 return operationInfo; 68 } 69 70 public OperationDesc buildOperationDesc() throws DeploymentException { 71 if (built) { 72 return operationDesc; 73 } 74 75 built = true; 76 77 operationDesc.setMethod(method); 78 79 83 Class [] methodParamTypes = method.getParameterTypes(); 85 List inputParts = input.getOrderedParts(null); 86 if (methodParamTypes.length != inputParts.size()) { 87 throw new DeploymentException("mismatch in parameter counts: method has " + methodParamTypes.length + " whereas the input message has " + inputParts.size()); 88 } 89 90 int i = 0; 92 for (Iterator parts = inputParts.iterator(); parts.hasNext();) { 93 Part part = (Part) parts.next(); 94 String partName = part.getName(); 95 QName name = new QName ("", partName); 96 byte mode = ParameterDesc.IN; 97 QName typeQName = part.getTypeName() == null ? part.getElementName() : part.getTypeName(); 98 Class javaClass = methodParamTypes[i++]; 99 ParameterDesc parameter = new ParameterDesc(name, mode, typeQName, javaClass, false, false); 101 operationDesc.addParameter(parameter); 102 } 103 104 if (output != null && output.getParts().size() > 1) { 106 throw new DeploymentException("Lightweight mapping has at most one part in the (optional) output message, not: " + output.getParts().size()); 107 } 108 109 if (output != null && output.getParts().size() == 1) { 111 Part part = (Part) output.getParts().values().iterator().next(); 112 113 QName returnName = part.getElementName() == null ? new QName (part.getName()) : part.getElementName(); 115 operationDesc.setReturnQName(returnName); 116 117 QName returnType = part.getTypeName() == null ? part.getElementName() : part.getTypeName(); 119 operationDesc.setReturnType(returnType); 120 121 operationDesc.setReturnClass(method.getReturnType()); 122 } 123 124 return operationDesc; 135 } 136 } 137 | Popular Tags |