Search in sources :

Example 1 with Operation

use of com.sun.tools.ws.processor.model.Operation in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method processSOAPOperation.

/* (non-Javadoc)
     * @see WSDLModelerBase#processSOAPOperation()
     */
protected Operation processSOAPOperation() {
    Operation operation = new Operation(new QName(null, info.bindingOperation.getName()), info.bindingOperation);
    setDocumentationIfPresent(operation, info.portTypeOperation.getDocumentation());
    if (info.portTypeOperation.getStyle() != OperationStyle.REQUEST_RESPONSE && info.portTypeOperation.getStyle() != OperationStyle.ONE_WAY) {
        if (options.isExtensionMode()) {
            warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName()));
            return null;
        } else {
            error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName(), info.port.resolveBinding(document).resolvePortType(document).getName()));
        }
    }
    SOAPStyle soapStyle = info.soapBinding.getStyle();
    // find out the SOAP operation extension, if any
    SOAPOperation soapOperation = (SOAPOperation) getExtensionOfType(info.bindingOperation, SOAPOperation.class);
    if (soapOperation != null) {
        if (soapOperation.getStyle() != null) {
            soapStyle = soapOperation.getStyle();
        }
        if (soapOperation.getSOAPAction() != null) {
            operation.setSOAPAction(soapOperation.getSOAPAction());
        }
    }
    operation.setStyle(soapStyle);
    String uniqueOperationName = getUniqueName(info.portTypeOperation, info.hasOverloadedOperations);
    if (info.hasOverloadedOperations) {
        operation.setUniqueName(uniqueOperationName);
    }
    info.operation = operation;
    // attachment
    SOAPBody soapRequestBody = getSOAPRequestBody();
    if (soapRequestBody == null) {
        // the WSDL document is invalid
        error(info.bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_INPUT_MISSING_SOAP_BODY(info.bindingOperation.getName()));
    }
    if (soapStyle == SOAPStyle.RPC) {
        if (soapRequestBody.isEncoded()) {
            if (options.isExtensionMode()) {
                warning(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED());
                processNonSOAPOperation();
            } else {
                error(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED());
            }
        }
        return processLiteralSOAPOperation(StyleAndUse.RPC_LITERAL);
    }
    // document style
    return processLiteralSOAPOperation(StyleAndUse.DOC_LITERAL);
}
Also used : QName(javax.xml.namespace.QName) Operation(com.sun.tools.ws.processor.model.Operation)

Example 2 with Operation

use of com.sun.tools.ws.processor.model.Operation in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method createJavaInterfaceForPort.

protected void createJavaInterfaceForPort(Port port, boolean isProvider) {
    if (isProvider) {
        createJavaInterfaceForProviderPort(port);
        return;
    }
    String interfaceName = getJavaNameOfSEI(port);
    if (isConflictingPortClassName(interfaceName)) {
        interfaceName += "_PortType";
    }
    JavaInterface intf = new JavaInterface(interfaceName);
    for (Operation operation : port.getOperations()) {
        createJavaMethodForOperation(port, operation, intf);
        for (JavaParameter jParam : operation.getJavaMethod().getParametersList()) {
            Parameter param = jParam.getParameter();
            if (param.getCustomName() != null) {
                jParam.setName(param.getCustomName());
            }
        }
    }
    port.setJavaInterface(intf);
}
Also used : Operation(com.sun.tools.ws.processor.model.Operation)

Example 3 with Operation

use of com.sun.tools.ws.processor.model.Operation in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method processLiteralSOAPOperation.

protected Operation processLiteralSOAPOperation(StyleAndUse styleAndUse) {
    // returns false if the operation name is not acceptable
    if (!applyOperationNameCustomization()) {
        return null;
    }
    boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
    Message inputMessage = getInputMessage();
    Request request = new Request(inputMessage, errReceiver);
    request.setErrorReceiver(errReceiver);
    info.operation.setUse(SOAPUse.LITERAL);
    info.operation.setWSDLPortTypeOperation(info.portTypeOperation);
    SOAPBody soapRequestBody = getSOAPRequestBody();
    if ((StyleAndUse.DOC_LITERAL == styleAndUse) && (soapRequestBody.getNamespace() != null)) {
        warning(soapRequestBody, ModelerMessages.WSDLMODELER_WARNING_R_2716("soapbind:body", info.bindingOperation.getName()));
    }
    Response response;
    SOAPBody soapResponseBody = null;
    Message outputMessage = null;
    if (isRequestResponse) {
        soapResponseBody = getSOAPResponseBody();
        if (isOperationDocumentLiteral(styleAndUse) && (soapResponseBody.getNamespace() != null)) {
            warning(soapResponseBody, ModelerMessages.WSDLMODELER_WARNING_R_2716("soapbind:body", info.bindingOperation.getName()));
        }
        outputMessage = getOutputMessage();
        response = new Response(outputMessage, errReceiver);
    } else {
        response = new Response(null, errReceiver);
    }
    // ignore operation if there are more than one root part
    if (!validateMimeParts(getMimeParts(info.bindingOperation.getInput())) || !validateMimeParts(getMimeParts(info.bindingOperation.getOutput()))) {
        return null;
    }
    if (!validateBodyParts(info.bindingOperation)) {
        // only to wsdNl:part element(s) that have been defined using the type attribute.
        if (isOperationDocumentLiteral(styleAndUse)) {
            if (options.isExtensionMode()) {
                warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_CANNOT_HANDLE_TYPE_MESSAGE_PART(info.portTypeOperation.getName()));
            } else {
                error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_DOCLITOPERATION(info.portTypeOperation.getName()));
            }
        } else if (isOperationRpcLiteral(styleAndUse)) {
            if (options.isExtensionMode()) {
                warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_CANNOT_HANDLE_ELEMENT_MESSAGE_PART(info.portTypeOperation.getName()));
            } else {
                error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_RPCLITOPERATION(info.portTypeOperation.getName()));
            }
        }
        return null;
    }
    // Process parameterOrder and get the parameterList
    List<MessagePart> parameterList = getParameterOrder();
    // binding is invalid in the wsdl, ignore the operation.
    if (!setMessagePartsBinding(styleAndUse)) {
        return null;
    }
    List<Parameter> params = null;
    boolean unwrappable = isUnwrappable();
    info.operation.setWrapped(unwrappable);
    if (isOperationDocumentLiteral(styleAndUse)) {
        params = getDoclitParameters(request, response, parameterList);
    } else if (isOperationRpcLiteral(styleAndUse)) {
        String operationName = info.bindingOperation.getName();
        Block reqBlock = null;
        if (inputMessage != null) {
            QName name = new QName(getRequestNamespaceURI(soapRequestBody), operationName);
            RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel());
            rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.ws.encoding.jaxb.RpcLitPayload", null));
            reqBlock = new Block(name, rpcStruct, inputMessage);
            request.addBodyBlock(reqBlock);
        }
        Block resBlock = null;
        if (isRequestResponse && outputMessage != null) {
            QName name = new QName(getResponseNamespaceURI(soapResponseBody), operationName + "Response");
            RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel());
            rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.ws.encoding.jaxb.RpcLitPayload", null));
            resBlock = new Block(name, rpcStruct, outputMessage);
            response.addBodyBlock(resBlock);
        }
        params = getRpcLitParameters(request, response, reqBlock, resBlock, parameterList);
    }
    if (!validateParameterName(params)) {
        return null;
    }
    // create a definitive list of parameters to match what we'd like to get
    // in the java interface (which is generated much later), parameterOrder
    List<Parameter> definitiveParameterList = new ArrayList<>();
    for (Parameter param : params) {
        if (param.isReturn()) {
            info.operation.setProperty(WSDL_RESULT_PARAMETER, param);
            response.addParameter(param);
            continue;
        }
        if (param.isIN()) {
            request.addParameter(param);
        } else if (param.isOUT()) {
            response.addParameter(param);
        } else if (param.isINOUT()) {
            request.addParameter(param);
            response.addParameter(param);
        }
        definitiveParameterList.add(param);
    }
    info.operation.setRequest(request);
    if (isRequestResponse) {
        info.operation.setResponse(response);
    }
    Iterator<Block> bb = request.getBodyBlocks();
    QName body;
    Operation thatOp;
    if (bb.hasNext()) {
        body = bb.next().getName();
        thatOp = uniqueBodyBlocks.get(body);
    } else {
        // there is no body block
        body = VOID_BODYBLOCK;
        thatOp = uniqueBodyBlocks.get(VOID_BODYBLOCK);
    }
    if (thatOp != null) {
        if (options.isExtensionMode()) {
            warning(info.port, ModelerMessages.WSDLMODELER_NON_UNIQUE_BODY_WARNING(info.port.getName(), info.operation.getName(), thatOp.getName(), body));
        } else {
            error(info.port, ModelerMessages.WSDLMODELER_NON_UNIQUE_BODY_ERROR(info.port.getName(), info.operation.getName(), thatOp.getName(), body));
        }
    } else {
        uniqueBodyBlocks.put(body, info.operation);
    }
    // Add additional headers
    if (options.additionalHeaders) {
        List<Parameter> additionalHeaders = new ArrayList<>();
        if (inputMessage != null) {
            for (MessagePart part : getAdditionHeaderParts(info.bindingOperation, inputMessage, true)) {
                QName name = part.getDescriptor();
                JAXBType jaxbType = getJAXBType(part);
                Block block = new Block(name, jaxbType, part);
                Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block);
                additionalHeaders.add(param);
                request.addHeaderBlock(block);
                request.addParameter(param);
                definitiveParameterList.add(param);
            }
        }
        if (isRequestResponse && outputMessage != null) {
            List<Parameter> outParams = new ArrayList<>();
            for (MessagePart part : getAdditionHeaderParts(info.bindingOperation, outputMessage, false)) {
                QName name = part.getDescriptor();
                JAXBType jaxbType = getJAXBType(part);
                Block block = new Block(name, jaxbType, part);
                Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block);
                param.setMode(Mode.OUT);
                outParams.add(param);
                response.addHeaderBlock(block);
                response.addParameter(param);
            }
            for (Parameter outParam : outParams) {
                for (Parameter inParam : additionalHeaders) {
                    if (inParam.getName().equals(outParam.getName()) && inParam.getBlock().getName().equals(outParam.getBlock().getName())) {
                        // it is INOUT
                        inParam.setMode(Mode.INOUT);
                        outParam.setMode(Mode.INOUT);
                        break;
                    }
                }
                if (outParam.isOUT()) {
                    definitiveParameterList.add(outParam);
                }
            }
        }
    }
    // faults with duplicate names
    Set duplicateNames = getDuplicateFaultNames();
    // handle soap:fault
    handleLiteralSOAPFault(response, duplicateNames);
    info.operation.setProperty(WSDL_PARAMETER_ORDER, definitiveParameterList);
    // set Async property
    Binding binding = info.port.resolveBinding(document);
    PortType portType = binding.resolvePortType(document);
    if (isAsync(portType, info.portTypeOperation)) {
        addAsyncOperations(info.operation, styleAndUse);
    }
    return info.operation;
}
Also used : JAXWSBinding(com.sun.tools.ws.wsdl.document.jaxws.JAXWSBinding) Message(com.sun.tools.ws.wsdl.document.Message) QName(javax.xml.namespace.QName) Operation(com.sun.tools.ws.processor.model.Operation)

Example 4 with Operation

use of com.sun.tools.ws.processor.model.Operation in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method processNonSOAPOperation.

/**
 * Returns an operation purely from abstract operation
 */
private Operation processNonSOAPOperation() {
    Operation operation = new Operation(new QName(null, info.bindingOperation.getName()), info.bindingOperation);
    setDocumentationIfPresent(operation, info.portTypeOperation.getDocumentation());
    if (info.portTypeOperation.getStyle() != OperationStyle.REQUEST_RESPONSE && info.portTypeOperation.getStyle() != OperationStyle.ONE_WAY) {
        if (options.isExtensionMode()) {
            warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName()));
            return null;
        } else {
            error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName(), info.port.resolveBinding(document).resolvePortType(document).getName()));
        }
    }
    boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
    Message inputMessage = getInputMessage();
    Request request = new Request(inputMessage, errReceiver);
    request.setErrorReceiver(errReceiver);
    info.operation = operation;
    info.operation.setWSDLPortTypeOperation(info.portTypeOperation);
    Response response;
    Message outputMessage = null;
    if (isRequestResponse) {
        outputMessage = getOutputMessage();
        response = new Response(outputMessage, errReceiver);
    } else {
        response = new Response(null, errReceiver);
    }
    // set the style based on heuristic that message has either all parts defined
    // using type(RPC) or element(DOCUMENT)
    setNonSoapStyle(inputMessage, outputMessage);
    // Process parameterOrder and get the parameterList
    List<MessagePart> parameterList = getParameterOrder();
    boolean unwrappable = isUnwrappable();
    info.operation.setWrapped(unwrappable);
    List<Parameter> params = getDoclitParameters(request, response, parameterList);
    if (!validateParameterName(params)) {
        return null;
    }
    // create a definitive list of parameters to match what we'd like to get
    // in the java interface (which is generated much later), parameterOrder
    List<Parameter> definitiveParameterList = new ArrayList<>();
    for (Parameter param : params) {
        if (param.isReturn()) {
            info.operation.setProperty(WSDL_RESULT_PARAMETER, param);
            response.addParameter(param);
            continue;
        }
        if (param.isIN()) {
            request.addParameter(param);
        } else if (param.isOUT()) {
            response.addParameter(param);
        } else if (param.isINOUT()) {
            request.addParameter(param);
            response.addParameter(param);
        }
        definitiveParameterList.add(param);
    }
    info.operation.setRequest(request);
    if (isRequestResponse) {
        info.operation.setResponse(response);
    }
    // faults with duplicate names
    Set duplicateNames = getDuplicateFaultNames();
    // handle soap:fault
    handleLiteralSOAPFault(response, duplicateNames);
    info.operation.setProperty(WSDL_PARAMETER_ORDER, definitiveParameterList);
    Binding binding = info.port.resolveBinding(document);
    PortType portType = binding.resolvePortType(document);
    if (isAsync(portType, info.portTypeOperation)) {
        warning(portType, "Can not generate Async methods for non-soap binding!");
    }
    return info.operation;
}
Also used : JAXWSBinding(com.sun.tools.ws.wsdl.document.jaxws.JAXWSBinding) Message(com.sun.tools.ws.wsdl.document.Message) QName(javax.xml.namespace.QName) Operation(com.sun.tools.ws.processor.model.Operation)

Example 5 with Operation

use of com.sun.tools.ws.processor.model.Operation in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method addAsyncOperations.

/**
 */
private void addAsyncOperations(Operation syncOperation, StyleAndUse styleAndUse) {
    Operation operation = createAsyncOperation(syncOperation, styleAndUse, AsyncOperationType.POLLING);
    if (operation != null) {
        info.modelPort.addOperation(operation);
    }
    operation = createAsyncOperation(syncOperation, styleAndUse, AsyncOperationType.CALLBACK);
    if (operation != null) {
        info.modelPort.addOperation(operation);
    }
}
Also used : Operation(com.sun.tools.ws.processor.model.Operation)

Aggregations

Operation (com.sun.tools.ws.processor.model.Operation)7 QName (javax.xml.namespace.QName)5 JAXWSBinding (com.sun.tools.ws.wsdl.document.jaxws.JAXWSBinding)3 Port (com.sun.tools.ws.processor.model.Port)2 Message (com.sun.tools.ws.wsdl.document.Message)2 JAnnotationUse (com.sun.codemodel.JAnnotationUse)1 JClass (com.sun.codemodel.JClass)1 JClassAlreadyExistsException (com.sun.codemodel.JClassAlreadyExistsException)1 JCommentPart (com.sun.codemodel.JCommentPart)1 JDefinedClass (com.sun.codemodel.JDefinedClass)1 JDocComment (com.sun.codemodel.JDocComment)1 JMethod (com.sun.codemodel.JMethod)1 JVar (com.sun.codemodel.JVar)1 Fault (com.sun.tools.ws.processor.model.Fault)1 JavaInterface (com.sun.tools.ws.processor.model.java.JavaInterface)1 JavaMethod (com.sun.tools.ws.processor.model.java.JavaMethod)1 JavaParameter (com.sun.tools.ws.processor.model.java.JavaParameter)1 JAXBTypeAndAnnotation (com.sun.tools.ws.processor.model.jaxb.JAXBTypeAndAnnotation)1 com.sun.tools.ws.wsdl.document (com.sun.tools.ws.wsdl.document)1 WebService (jakarta.jws.WebService)1