Search in sources :

Example 1 with JaxRpcParameterInfo

use of org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo in project tomee by apache.

the class JavaServiceDescBuilder method buildOperationDesc.

private OperationDesc buildOperationDesc(JaxRpcOperationInfo operationInfo, Class serviceEndpointInterface) throws OpenEJBException {
    OperationDesc operationDesc = new OperationDesc();
    operationDesc.setName(operationInfo.name);
    // Binding type
    switch(operationInfo.bindingStyle) {
        case RPC_ENCODED:
            operationDesc.setStyle(Style.RPC);
            operationDesc.setUse(Use.ENCODED);
            break;
        case RPC_LITERAL:
            operationDesc.setStyle(Style.RPC);
            operationDesc.setUse(Use.LITERAL);
            break;
        case DOCUMENT_ENCODED:
            operationDesc.setStyle(Style.DOCUMENT);
            operationDesc.setUse(Use.ENCODED);
            break;
        case DOCUMENT_LITERAL:
            operationDesc.setStyle(Style.DOCUMENT);
            operationDesc.setUse(Use.LITERAL);
            break;
        case DOCUMENT_LITERAL_WRAPPED:
            operationDesc.setStyle(Style.WRAPPED);
            operationDesc.setUse(Use.LITERAL);
            break;
    }
    // Operation style
    switch(operationInfo.operationStyle) {
        case NOTIFICATION:
            operationDesc.setMep(OperationType.NOTIFICATION);
            break;
        case ONE_WAY:
            operationDesc.setMep(OperationType.ONE_WAY);
            break;
        case REQUEST_RESPONSE:
            operationDesc.setMep(OperationType.REQUEST_RESPONSE);
            break;
        case SOLICIT_RESPONSE:
            operationDesc.setMep(OperationType.SOLICIT_RESPONSE);
            break;
    }
    // Build parameters
    Class[] paramTypes = new Class[operationInfo.parameters.size()];
    int i = 0;
    for (JaxRpcParameterInfo parameterInfo : operationInfo.parameters) {
        ParameterDesc parameterDesc = buildParameterDesc(parameterInfo);
        operationDesc.addParameter(parameterDesc);
        paramTypes[i++] = parameterDesc.getJavaType();
    }
    // Java method
    try {
        Method method = serviceEndpointInterface.getMethod(operationInfo.javaMethodName, paramTypes);
        operationDesc.setMethod(method);
    } catch (NoSuchMethodException e) {
        String args = "";
        for (Class paramType : paramTypes) {
            if (args.length() > 0) {
                args += ", ";
            }
            args += paramType.getName();
        }
        throw new OpenEJBException("Mapping references non-existent method in service-endpoint: " + operationInfo.javaMethodName + "(" + args + ")");
    }
    // 
    if (operationInfo.returnQName != null) {
        operationDesc.setReturnQName(operationInfo.returnQName);
        operationDesc.setReturnType(operationInfo.returnXmlType);
        try {
            Class<?> returnClass = classLoader.loadClass(operationInfo.returnJavaType);
            operationDesc.setReturnClass(returnClass);
        } catch (ClassNotFoundException e) {
            throw new OpenEJBException();
        }
    } else if (operationInfo.operationStyle == JaxRpcOperationInfo.OperationStyle.REQUEST_RESPONSE) {
        operationDesc.setReturnQName(null);
        operationDesc.setReturnType(XMLType.AXIS_VOID);
        operationDesc.setReturnClass(void.class);
    }
    // Build faults
    for (JaxRpcFaultInfo faultInfo : operationInfo.faults) {
        FaultDesc faultDesc = buildFaultDesc(faultInfo);
        operationDesc.addFault(faultDesc);
    }
    return operationDesc;
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc) OpenEJBException(org.apache.openejb.OpenEJBException) JaxRpcFaultInfo(org.apache.openejb.server.axis.assembler.JaxRpcFaultInfo) OperationDesc(org.apache.axis.description.OperationDesc) Method(java.lang.reflect.Method) JaxRpcParameterInfo(org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo) FaultDesc(org.apache.axis.description.FaultDesc)

Example 2 with JaxRpcParameterInfo

use of org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo in project tomee by apache.

the class JavaServiceDescBuilder method buildFaultDesc.

private FaultDesc buildFaultDesc(JaxRpcFaultInfo faultInfo) throws OpenEJBException {
    FaultDesc faultDesc = new FaultDesc(faultInfo.qname, faultInfo.javaType, faultInfo.xmlType, faultInfo.complex);
    ArrayList<ParameterDesc> parameters = new ArrayList<ParameterDesc>();
    for (JaxRpcParameterInfo parameterInfo : faultInfo.parameters) {
        ParameterDesc parameterDesc = buildParameterDesc(parameterInfo);
        parameters.add(parameterDesc);
    }
    faultDesc.setParameters(parameters);
    return faultDesc;
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc) JaxRpcParameterInfo(org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo) ArrayList(java.util.ArrayList) FaultDesc(org.apache.axis.description.FaultDesc)

Aggregations

FaultDesc (org.apache.axis.description.FaultDesc)2 ParameterDesc (org.apache.axis.description.ParameterDesc)2 JaxRpcParameterInfo (org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 OperationDesc (org.apache.axis.description.OperationDesc)1 OpenEJBException (org.apache.openejb.OpenEJBException)1 JaxRpcFaultInfo (org.apache.openejb.server.axis.assembler.JaxRpcFaultInfo)1