use of org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo.Mode in project tomee by apache.
the class HeavyweightOperationInfoBuilder method mapParameter.
private JaxRpcParameterInfo mapParameter(MethodParamPartsMapping paramMapping) throws OpenEJBException {
WsdlMessageMapping wsdlMessageMappingType = paramMapping.getWsdlMessageMapping();
QName wsdlMessageQName = wsdlMessageMappingType.getWsdlMessage();
String wsdlMessagePartName = wsdlMessageMappingType.getWsdlMessagePartName();
Mode mode = Mode.valueOf(wsdlMessageMappingType.getParameterMode());
if ((mode == Mode.OUT || mode == Mode.INOUT) && outputMessage == null) {
throw new OpenEJBException("Mapping for output parameter " + wsdlMessagePartName + " found, but no output message for operation " + operationName);
}
//
// Determine the param qname and xml schema type
//
QName paramQName;
QName paramXmlType;
if (mode == Mode.IN || mode == Mode.INOUT) {
//
if (!wsdlMessageQName.equals(inputMessage.getQName())) {
throw new OpenEJBException("QName of input message: " + inputMessage.getQName() + " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
}
Part part = null;
XmlElementInfo inParameter = null;
if (bindingStyle.isWrapped()) {
Part inPart = getWrappedPart(inputMessage);
// operation name == wraper element name
QName name = inPart.getElementName();
if (!name.getLocalPart().equals(operationName)) {
throw new OpenEJBException("message " + inputMessage.getQName() + " refers to a global element named " + name.getLocalPart() + ", which is not equal to the operation name " + operationName);
}
inParameter = getWrapperChild(inPart, wsdlMessagePartName);
paramQName = new QName("", inParameter.qname.getLocalPart());
paramXmlType = inParameter.xmlType;
} else if (bindingStyle.isRpc()) {
part = inputMessage.getPart(wsdlMessagePartName);
if (part == null) {
throw new OpenEJBException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in input message for operation " + operationName);
}
paramQName = new QName("", part.getName());
// RPC can only use type
paramXmlType = part.getTypeName();
} else {
part = inputMessage.getPart(wsdlMessagePartName);
if (part == null) {
throw new OpenEJBException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in input message for operation " + operationName);
}
// Document should use element, but type is allowed
paramQName = getPartName(part);
paramXmlType = paramQName;
}
inParamNames.add(wsdlMessagePartName);
//
if (mode == Mode.INOUT) {
if (bindingStyle.isWrapped()) {
// Verify output message supports this inout parameter
Part outPart = getWrappedPart(outputMessage);
XmlElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
if (inParameter.xmlType != outParameter.xmlType) {
throw new OpenEJBException("The wrapper children " + wsdlMessagePartName + " do not have the same type for operation " + operationName);
}
} else if (bindingStyle.isRpc()) {
// Verify output message supports this inout parameter
Part outPart = outputMessage.getPart(wsdlMessagePartName);
if (outPart == null) {
throw new OpenEJBException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for INOUT parameter of operation " + operationName);
}
// TODO this cannot happen.
if (!part.getName().equals(outPart.getName())) {
throw new OpenEJBException("Mismatched input part name: " + part.getName() + " and output part name: " + outPart.getName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
}
if (!(part.getElementName() == null ? outPart.getElementName() == null : part.getElementName().equals(outPart.getElementName()))) {
throw new OpenEJBException("Mismatched input part element name: " + part.getElementName() + " and output part element name: " + outPart.getElementName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
}
if (!(part.getTypeName() == null ? outPart.getTypeName() == null : part.getTypeName().equals(outPart.getTypeName()))) {
throw new OpenEJBException("Mismatched input part type name: " + part.getTypeName() + " and output part type name: " + outPart.getTypeName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
}
} else {
part = outputMessage.getPart(wsdlMessagePartName);
if (part == null) {
throw new OpenEJBException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
}
// todo this seem strange... shouldn't the name and type be the same as the in binding above
paramQName = getPartName(part);
paramXmlType = paramQName;
}
outParamNames.add(wsdlMessagePartName);
}
} else {
//
if (!wsdlMessageQName.equals(outputMessage.getQName())) {
throw new OpenEJBException("QName of output message: " + outputMessage.getQName() + " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
}
if (bindingStyle.isWrapped()) {
Part outPart = getWrappedPart(outputMessage);
XmlElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
paramQName = new QName("", outParameter.qname.getLocalPart());
paramXmlType = outParameter.xmlType;
} else if (bindingStyle.isRpc()) {
Part part = outputMessage.getPart(wsdlMessagePartName);
if (part == null) {
throw new OpenEJBException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
}
paramQName = new QName("", part.getName());
// RPC can only use type
paramXmlType = part.getTypeName();
} else {
Part part = outputMessage.getPart(wsdlMessagePartName);
if (part == null) {
throw new OpenEJBException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
}
paramQName = getPartName(part);
paramXmlType = paramQName;
}
outParamNames.add(wsdlMessagePartName);
}
//
// Determine the param java type
//
String paramJavaType;
if (mode == Mode.IN) {
// IN only prarmeters don't have holders
paramJavaType = paramMapping.getParamType();
} else if (rpcHolderClasses.containsKey(paramMapping.getParamType())) {
// This is a standard type with a built in holder class
paramJavaType = rpcHolderClasses.get(paramMapping.getParamType());
} else {
// holderClass == ${packageName}.holders.${typeName}Holder
String packageName;
String typeName;
PackageMapping packageMapping = mapping.getPackageMappingMap().get(paramXmlType.getNamespaceURI());
if (packageMapping != null) {
packageName = packageMapping.getPackageType();
// Type name is typeQName local part, but make sure it is capitalized correctly
typeName = paramXmlType.getLocalPart();
typeName = Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1);
} else {
// a.b.foo.Bar >>> a.b.foo.holders.BarHolder
String paramJavaTypeName = paramMapping.getParamType();
int lastDot = paramJavaTypeName.lastIndexOf(".");
packageName = paramJavaTypeName.substring(0, lastDot);
typeName = paramJavaTypeName.substring(lastDot + 1);
}
paramJavaType = packageName + ".holders." + typeName + "Holder";
}
//
// Build JaxRpcParameterInfo
//
JaxRpcParameterInfo parameterInfo = new JaxRpcParameterInfo();
parameterInfo.qname = paramQName;
parameterInfo.xmlType = paramXmlType;
parameterInfo.javaType = paramJavaType;
parameterInfo.mode = Mode.valueOf(wsdlMessageMappingType.getParameterMode());
parameterInfo.soapHeader = wsdlMessageMappingType.getSoapHeader() != null;
return parameterInfo;
}
Aggregations