Search in sources :

Example 1 with Message

use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method getDoclitParameters.

private List<Parameter> getDoclitParameters(Request req, Response res, List<MessagePart> parameterList) {
    if (parameterList.isEmpty()) {
        return new ArrayList<>();
    }
    List<Parameter> params = new ArrayList<>();
    Message inMsg = getInputMessage();
    Message outMsg = getOutputMessage();
    boolean unwrappable = isUnwrappable();
    List<Parameter> outParams = null;
    int pIndex = 0;
    for (MessagePart part : parameterList) {
        QName reqBodyName = part.getDescriptor();
        JAXBType jaxbType = getJAXBType(part);
        Block block = new Block(reqBodyName, jaxbType, part);
        if (unwrappable) {
            // So build body and header blocks and set to request and response
            JAXBStructuredType jaxbStructType = ModelerUtils.createJAXBStructureType(jaxbType);
            block = new Block(reqBodyName, jaxbStructType, part);
            if (ModelerUtils.isBoundToSOAPBody(part)) {
                if (part.isIN()) {
                    req.addBodyBlock(block);
                } else if (part.isOUT()) {
                    res.addBodyBlock(block);
                } else if (part.isINOUT()) {
                    req.addBodyBlock(block);
                    res.addBodyBlock(block);
                }
            } else if (ModelerUtils.isUnbound(part)) {
                if (part.isIN()) {
                    req.addUnboundBlock(block);
                } else if (part.isOUT()) {
                    res.addUnboundBlock(block);
                } else if (part.isINOUT()) {
                    req.addUnboundBlock(block);
                    res.addUnboundBlock(block);
                }
            }
            if (part.isIN() || part.isINOUT()) {
                params = ModelerUtils.createUnwrappedParameters(jaxbStructType, block);
                int index = 0;
                Mode mode = part.isINOUT() ? Mode.INOUT : Mode.IN;
                for (Parameter param : params) {
                    param.setParameterIndex(index++);
                    param.setMode(mode);
                    setCustomizedParameterName(info.portTypeOperation, inMsg, part, param, unwrappable);
                }
            } else if (part.isOUT()) {
                outParams = ModelerUtils.createUnwrappedParameters(jaxbStructType, block);
                for (Parameter param : outParams) {
                    param.setMode(Mode.OUT);
                    setCustomizedParameterName(info.portTypeOperation, outMsg, part, param, unwrappable);
                }
            }
        } else {
            if (ModelerUtils.isBoundToSOAPBody(part)) {
                if (part.isIN()) {
                    req.addBodyBlock(block);
                } else if (part.isOUT()) {
                    res.addBodyBlock(block);
                } else if (part.isINOUT()) {
                    req.addBodyBlock(block);
                    res.addBodyBlock(block);
                }
            } else if (ModelerUtils.isBoundToSOAPHeader(part)) {
                if (part.isIN()) {
                    req.addHeaderBlock(block);
                } else if (part.isOUT()) {
                    res.addHeaderBlock(block);
                } else if (part.isINOUT()) {
                    req.addHeaderBlock(block);
                    res.addHeaderBlock(block);
                }
            } else if (ModelerUtils.isBoundToMimeContent(part)) {
                List<MIMEContent> mimeContents;
                if (part.isIN()) {
                    mimeContents = getMimeContents(info.bindingOperation.getInput(), getInputMessage(), part.getName());
                    jaxbType = getAttachmentType(mimeContents, part);
                    block = new Block(jaxbType.getName(), jaxbType, part);
                    req.addAttachmentBlock(block);
                } else if (part.isOUT()) {
                    mimeContents = getMimeContents(info.bindingOperation.getOutput(), getOutputMessage(), part.getName());
                    jaxbType = getAttachmentType(mimeContents, part);
                    block = new Block(jaxbType.getName(), jaxbType, part);
                    res.addAttachmentBlock(block);
                } else if (part.isINOUT()) {
                    mimeContents = getMimeContents(info.bindingOperation.getInput(), getInputMessage(), part.getName());
                    jaxbType = getAttachmentType(mimeContents, part);
                    block = new Block(jaxbType.getName(), jaxbType, part);
                    req.addAttachmentBlock(block);
                    res.addAttachmentBlock(block);
                    mimeContents = getMimeContents(info.bindingOperation.getOutput(), getOutputMessage(), part.getName());
                    JAXBType outJaxbType = getAttachmentType(mimeContents, part);
                    String inType = jaxbType.getJavaType().getType().getName();
                    String outType = outJaxbType.getJavaType().getType().getName();
                    TypeAndAnnotation inTa = jaxbType.getJavaType().getType().getTypeAnn();
                    TypeAndAnnotation outTa = outJaxbType.getJavaType().getType().getTypeAnn();
                    if ((((inTa != null) && (outTa != null) && inTa.equals(outTa))) && !inType.equals(outType)) {
                        String javaType = "jakarta.activation.DataHandler";
                        // S2JJAXBModel jaxbModel = getJAXBModelBuilder().getJAXBModel().getS2JJAXBModel();
                        // JCodeModel cm = jaxbModel.generateCode(null, errReceiver);
                        JType jt = options.getCodeModel().ref(javaType);
                        JAXBTypeAndAnnotation jaxbTa = jaxbType.getJavaType().getType();
                        jaxbTa.setType(jt);
                    }
                }
            } else if (ModelerUtils.isUnbound(part)) {
                if (part.isIN()) {
                    req.addUnboundBlock(block);
                } else if (part.isOUT()) {
                    res.addUnboundBlock(block);
                } else if (part.isINOUT()) {
                    req.addUnboundBlock(block);
                    res.addUnboundBlock(block);
                }
            }
            Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block);
            param.setMode(part.getMode());
            if (part.isReturn()) {
                param.setParameterIndex(-1);
            } else {
                param.setParameterIndex(pIndex++);
            }
            if (part.isIN()) {
                setCustomizedParameterName(info.bindingOperation, inMsg, part, param, false);
            } else if (outMsg != null) {
                setCustomizedParameterName(info.bindingOperation, outMsg, part, param, false);
            }
            params.add(param);
        }
    }
    if (unwrappable && (outParams != null)) {
        int index = params.size();
        for (Parameter param : outParams) {
            if (BindingHelper.mangleNameToVariableName(param.getName()).equals("return")) {
                param.setParameterIndex(-1);
            } else {
                Parameter inParam = ModelerUtils.getParameter(param.getName(), params);
                if ((inParam != null) && inParam.isIN()) {
                    QName inElementName = inParam.getType().getName();
                    QName outElementName = param.getType().getName();
                    String inJavaType = inParam.getTypeName();
                    String outJavaType = param.getTypeName();
                    TypeAndAnnotation inTa = inParam.getType().getJavaType().getType().getTypeAnn();
                    TypeAndAnnotation outTa = param.getType().getJavaType().getType().getTypeAnn();
                    QName inRawTypeName = ModelerUtils.getRawTypeName(inParam);
                    QName outRawTypeName = ModelerUtils.getRawTypeName(param);
                    if (inElementName.getLocalPart().equals(outElementName.getLocalPart()) && inJavaType.equals(outJavaType) && (inTa == null || outTa == null || inTa.equals(outTa)) && (inRawTypeName == null || outRawTypeName == null || inRawTypeName.equals(outRawTypeName))) {
                        inParam.setMode(Mode.INOUT);
                        continue;
                    }
                }
                if (outParams.size() == 1) {
                    param.setParameterIndex(-1);
                } else {
                    param.setParameterIndex(index++);
                }
            }
            params.add(param);
        }
    }
    return params;
}
Also used : Message(com.sun.tools.ws.wsdl.document.Message) QName(javax.xml.namespace.QName) Mode(jakarta.jws.WebParam.Mode) TypeAndAnnotation(com.sun.tools.xjc.api.TypeAndAnnotation) MIMEContent(com.sun.tools.ws.wsdl.document.mime.MIMEContent) JType(com.sun.codemodel.JType)

Example 2 with Message

use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method getRpcLitParameters.

private List<Parameter> getRpcLitParameters(Request req, Response res, Block reqBlock, Block resBlock, List<MessagePart> paramList) {
    List<Parameter> params = new ArrayList<>();
    Message inMsg = getInputMessage();
    Message outMsg = getOutputMessage();
    S2JJAXBModel jaxbModel = ((RpcLitStructure) reqBlock.getType()).getJaxbModel().getS2JJAXBModel();
    List<Parameter> inParams = ModelerUtils.createRpcLitParameters(inMsg, reqBlock, jaxbModel, errReceiver);
    List<Parameter> outParams = null;
    if (outMsg != null) {
        outParams = ModelerUtils.createRpcLitParameters(outMsg, resBlock, jaxbModel, errReceiver);
    }
    // create parameters for header and mime parts
    int index = 0;
    for (MessagePart part : paramList) {
        Parameter param = null;
        if (ModelerUtils.isBoundToSOAPBody(part)) {
            if (part.isIN()) {
                param = ModelerUtils.getParameter(part.getName(), inParams);
            } else if (outParams != null) {
                param = ModelerUtils.getParameter(part.getName(), outParams);
            }
        } else if (ModelerUtils.isBoundToSOAPHeader(part)) {
            QName headerName = part.getDescriptor();
            JAXBType jaxbType = getJAXBType(part);
            Block headerBlock = new Block(headerName, jaxbType, part);
            param = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock);
            if (part.isIN()) {
                req.addHeaderBlock(headerBlock);
            } else if (part.isOUT()) {
                res.addHeaderBlock(headerBlock);
            } else if (part.isINOUT()) {
                req.addHeaderBlock(headerBlock);
                res.addHeaderBlock(headerBlock);
            }
        } else if (ModelerUtils.isBoundToMimeContent(part)) {
            List<MIMEContent> mimeContents;
            if (part.isIN() || part.isINOUT()) {
                mimeContents = getMimeContents(info.bindingOperation.getInput(), getInputMessage(), part.getName());
            } else {
                mimeContents = getMimeContents(info.bindingOperation.getOutput(), getOutputMessage(), part.getName());
            }
            JAXBType type = getAttachmentType(mimeContents, part);
            // create Parameters in request or response
            // Block mimeBlock = new Block(new QName(part.getName()), type);
            Block mimeBlock = new Block(type.getName(), type, part);
            param = ModelerUtils.createParameter(part.getName(), type, mimeBlock);
            if (part.isIN()) {
                req.addAttachmentBlock(mimeBlock);
            } else if (part.isOUT()) {
                res.addAttachmentBlock(mimeBlock);
            } else if (part.isINOUT()) {
                mimeContents = getMimeContents(info.bindingOperation.getOutput(), getOutputMessage(), part.getName());
                JAXBType outJaxbType = getAttachmentType(mimeContents, part);
                String inType = type.getJavaType().getType().getName();
                String outType = outJaxbType.getJavaType().getType().getName();
                if (!inType.equals(outType)) {
                    String javaType = "jakarta.activation.DataHandler";
                    JType jt = options.getCodeModel().ref(javaType);
                    JAXBTypeAndAnnotation jaxbTa = type.getJavaType().getType();
                    jaxbTa.setType(jt);
                }
                req.addAttachmentBlock(mimeBlock);
                res.addAttachmentBlock(mimeBlock);
            }
        } else if (ModelerUtils.isUnbound(part)) {
            QName name = part.getDescriptor();
            JAXBType type = getJAXBType(part);
            Block unboundBlock = new Block(name, type, part);
            if (part.isIN()) {
                req.addUnboundBlock(unboundBlock);
            } else if (part.isOUT()) {
                res.addUnboundBlock(unboundBlock);
            } else if (part.isINOUT()) {
                req.addUnboundBlock(unboundBlock);
                res.addUnboundBlock(unboundBlock);
            }
            param = ModelerUtils.createParameter(part.getName(), type, unboundBlock);
        }
        if (param != null) {
            if (part.isReturn()) {
                param.setParameterIndex(-1);
            } else {
                param.setParameterIndex(index++);
            }
            param.setMode(part.getMode());
            params.add(param);
        }
    }
    for (Parameter param : params) {
        if (param.isIN()) {
            setCustomizedParameterName(info.portTypeOperation, inMsg, inMsg.getPart(param.getName()), param, false);
        } else if (outMsg != null) {
            setCustomizedParameterName(info.portTypeOperation, outMsg, outMsg.getPart(param.getName()), param, false);
        }
    }
    return params;
}
Also used : Message(com.sun.tools.ws.wsdl.document.Message) QName(javax.xml.namespace.QName) MIMEContent(com.sun.tools.ws.wsdl.document.mime.MIMEContent) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel) JType(com.sun.codemodel.JType)

Example 3 with Message

use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.

the class WSDLModeler method isUnwrappable.

protected boolean isUnwrappable() {
    if (!getWrapperStyleCustomization()) {
        return false;
    }
    com.sun.tools.ws.wsdl.document.Message inputMessage = getInputMessage();
    com.sun.tools.ws.wsdl.document.Message outputMessage = getOutputMessage();
    // only a single part
    if ((inputMessage != null && inputMessage.numParts() != 1) || (outputMessage != null && outputMessage.numParts() != 1)) {
        return false;
    }
    MessagePart inputPart = inputMessage != null ? inputMessage.parts().next() : null;
    MessagePart outputPart = outputMessage != null ? outputMessage.parts().next() : null;
    String operationName = info.portTypeOperation.getName();
    // Wrapper style if the output message part refers to a global element declaration
    if ((inputPart != null && !inputPart.getDescriptor().getLocalPart().equals(operationName)) || (outputPart != null && outputPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT)) {
        return false;
    }
    // in that case the operation is not wrapper style
    if (((inputPart != null) && (inputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING)) || ((outputPart != null) && (outputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING))) {
        return false;
    }
    // if(inputPart != null && outputPart != null){
    if (inputPart != null) {
        boolean inputWrappable = false;
        JAXBType inputType = getJAXBType(inputPart);
        if (inputType != null) {
            inputWrappable = inputType.isUnwrappable();
        }
        // if there are no output part (oneway), the operation can still be wrapper style
        if (outputPart == null) {
            return inputWrappable;
        }
        JAXBType outputType = getJAXBType(outputPart);
        if ((inputType != null) && (outputType != null)) {
            return inputType.isUnwrappable() && outputType.isUnwrappable();
        }
    }
    return false;
}
Also used : Message(com.sun.tools.ws.wsdl.document.Message) com.sun.tools.ws.wsdl.document(com.sun.tools.ws.wsdl.document)

Example 4 with Message

use of com.sun.tools.ws.wsdl.document.Message 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 5 with Message

use of com.sun.tools.ws.wsdl.document.Message 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)

Aggregations

Message (com.sun.tools.ws.wsdl.document.Message)17 QName (javax.xml.namespace.QName)9 com.sun.tools.ws.wsdl.document (com.sun.tools.ws.wsdl.document)3 MIMEContent (com.sun.tools.ws.wsdl.document.mime.MIMEContent)3 java.util (java.util)3 JType (com.sun.codemodel.JType)2 Operation (com.sun.tools.ws.processor.model.Operation)2 JAXWSBinding (com.sun.tools.ws.wsdl.document.jaxws.JAXWSBinding)2 S2JJAXBModel (com.sun.tools.xjc.api.S2JJAXBModel)2 Iterator (java.util.Iterator)2 Element (org.w3c.dom.Element)2 TWSDLExtensible (com.sun.tools.ws.api.wsdl.TWSDLExtensible)1 Fault (com.sun.tools.ws.processor.model.Fault)1 Binding (com.sun.tools.ws.wsdl.document.Binding)1 Definitions (com.sun.tools.ws.wsdl.document.Definitions)1 MessagePart (com.sun.tools.ws.wsdl.document.MessagePart)1 PortType (com.sun.tools.ws.wsdl.document.PortType)1 Service (com.sun.tools.ws.wsdl.document.Service)1 TypeAndAnnotation (com.sun.tools.xjc.api.TypeAndAnnotation)1 Mode (jakarta.jws.WebParam.Mode)1