Search in sources :

Example 6 with Message

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

the class WSDLModeler method getAsynParameterOrder.

protected java.util.List<String> getAsynParameterOrder() {
    // for async operation ignore the parameterOrder
    java.util.List<String> parameterList = new ArrayList<>();
    Message inputMessage = getInputMessage();
    List<MessagePart> inputParts = inputMessage.getParts();
    for (MessagePart part : inputParts) {
        parameterList.add(part.getName());
    }
    return parameterList;
}
Also used : java.util(java.util) Message(com.sun.tools.ws.wsdl.document.Message)

Example 7 with Message

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

the class WSDLModeler method handleLiteralSOAPFault.

protected void handleLiteralSOAPFault(Response response, Set duplicateNames) {
    for (BindingFault bindingFault : info.bindingOperation.faults()) {
        com.sun.tools.ws.wsdl.document.Fault portTypeFault = null;
        for (com.sun.tools.ws.wsdl.document.Fault aFault : info.portTypeOperation.faults()) {
            if (aFault.getName().equals(bindingFault.getName())) {
                if (portTypeFault != null) {
                    // the WSDL document is invalid, a wsld:fault in a wsdl:operation of a portType can be bound only once
                    error(portTypeFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_UNIQUE(bindingFault.getName(), info.bindingOperation.getName()));
                }
                portTypeFault = aFault;
            }
        }
        // The WSDL document is invalid, the wsdl:fault in abstract operation is does not have any binding
        if (portTypeFault == null) {
            error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_FOUND(bindingFault.getName(), info.bindingOperation.getName()));
        }
    }
    for (com.sun.tools.ws.wsdl.document.Fault portTypeFault : info.portTypeOperation.faults()) {
        BindingFault bindingFault = null;
        for (BindingFault bFault : info.bindingOperation.faults()) {
            if (bFault.getName().equals(portTypeFault.getName())) {
                bindingFault = bFault;
            }
        }
        if (bindingFault == null) {
            warning(portTypeFault, ModelerMessages.WSDLMODELER_INVALID_PORT_TYPE_FAULT_NOT_FOUND(portTypeFault.getName(), info.portTypeOperation.getName()));
        }
        // wsdl:fault message name is used to create the java exception name later on
        String faultName = getFaultClassName(portTypeFault);
        Fault fault = new Fault(faultName, portTypeFault);
        fault.setWsdlFaultName(portTypeFault.getName());
        setDocumentationIfPresent(fault, portTypeFault.getDocumentation());
        if (bindingFault != null) {
            // get the soapbind:fault from wsdl:fault in the binding
            SOAPFault soapFault = (SOAPFault) getExtensionOfType(bindingFault, SOAPFault.class);
            // The WSDL document is invalid, can't have wsdl:fault without soapbind:fault
            if (soapFault == null) {
                if (options.isExtensionMode()) {
                    warning(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(), info.bindingOperation.getName()));
                    soapFault = new SOAPFault(new LocatorImpl());
                } else {
                    error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(), info.bindingOperation.getName()));
                }
            }
            // the soapbind:fault must have use="literal" or no use attribute, in that case its assumed "literal"
            if (!soapFault.isLiteral()) {
                if (options.isExtensionMode()) {
                    warning(soapFault, ModelerMessages.WSDLMODELER_WARNING_IGNORING_FAULT_NOT_LITERAL(bindingFault.getName(), info.bindingOperation.getName()));
                } else {
                    error(soapFault, ModelerMessages.WSDLMODELER_INVALID_OPERATION_FAULT_NOT_LITERAL(bindingFault.getName(), info.bindingOperation.getName()));
                }
                continue;
            }
            // the soapFault name must be present
            if (soapFault.getName() == null) {
                warning(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NO_SOAP_FAULT_NAME(bindingFault.getName(), info.bindingOperation.getName()));
            } else if (!soapFault.getName().equals(bindingFault.getName())) {
                warning(soapFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_WRONG_SOAP_FAULT_NAME(soapFault.getName(), bindingFault.getName(), info.bindingOperation.getName()));
            } else if (soapFault.getNamespace() != null) {
                warning(soapFault, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:fault", soapFault.getName()));
            }
        }
        com.sun.tools.ws.wsdl.document.Message faultMessage = portTypeFault.resolveMessage(info.document);
        Iterator iter2 = faultMessage.parts();
        if (!iter2.hasNext()) {
            // the WSDL document is invalid
            error(faultMessage, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_EMPTY_MESSAGE(portTypeFault.getName(), faultMessage.getName()));
        }
        MessagePart faultPart = (MessagePart) iter2.next();
        QName faultQName = faultPart.getDescriptor();
        // Don't include fault messages with non-unique soap:fault names
        if (duplicateNames.contains(faultQName)) {
            warning(faultPart, ModelerMessages.WSDLMODELER_DUPLICATE_FAULT_SOAP_NAME(portTypeFault.getName(), info.portTypeOperation.getName(), faultPart.getName()));
            continue;
        }
        if (iter2.hasNext()) {
            // the WSDL document is invalid
            error(faultMessage, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_MESSAGE_HAS_MORE_THAN_ONE_PART(portTypeFault.getName(), faultMessage.getName()));
        }
        if (faultPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) {
            if (options.isExtensionMode()) {
                warning(faultPart, ModelerMessages.WSDLMODELER_INVALID_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(faultMessage.getName(), faultPart.getName()));
            } else {
                error(faultPart, ModelerMessages.WSDLMODELER_INVALID_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(faultMessage.getName(), faultPart.getName()));
            }
        }
        JAXBType jaxbType = getJAXBType(faultPart);
        fault.setElementName(faultPart.getDescriptor());
        fault.setJavaMemberName(Names.getExceptionClassMemberName());
        Block faultBlock = new Block(faultQName, jaxbType, faultPart);
        fault.setBlock(faultBlock);
        // createSubfaults(fault);
        if (!response.getFaultBlocksMap().containsKey(faultBlock.getName())) {
            response.addFaultBlock(faultBlock);
        }
        info.operation.addFault(fault);
    }
}
Also used : Message(com.sun.tools.ws.wsdl.document.Message) QName(javax.xml.namespace.QName) com.sun.tools.ws.wsdl.document(com.sun.tools.ws.wsdl.document) Fault(com.sun.tools.ws.processor.model.Fault) LocatorImpl(org.xml.sax.helpers.LocatorImpl)

Example 8 with Message

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

the class WSDLModeler method handleLiteralSOAPHeaders.

protected void handleLiteralSOAPHeaders(Request request, Response response, Iterator headerParts, Set duplicateNames, @NotNull List<String> definitiveParameterList, boolean processRequest) {
    QName headerName;
    Block headerBlock;
    JAXBType jaxbType;
    int parameterOrderPosition = definitiveParameterList.size();
    while (headerParts.hasNext()) {
        MessagePart part = (MessagePart) headerParts.next();
        headerName = part.getDescriptor();
        jaxbType = getJAXBType(part);
        headerBlock = new Block(headerName, jaxbType, part);
        TWSDLExtensible ext;
        if (processRequest) {
            ext = info.bindingOperation.getInput();
        } else {
            ext = info.bindingOperation.getOutput();
        }
        Message headerMessage = getHeaderMessage(part, ext);
        if (processRequest) {
            request.addHeaderBlock(headerBlock);
        } else {
            response.addHeaderBlock(headerBlock);
        }
        Parameter parameter = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock);
        parameter.setParameterIndex(parameterOrderPosition);
        setCustomizedParameterName(info.bindingOperation, headerMessage, part, parameter, false);
        if (processRequest) {
            request.addParameter(parameter);
            definitiveParameterList.add(parameter.getName());
        } else {
            for (String inParamName : definitiveParameterList) {
                if (inParamName.equals(parameter.getName())) {
                    Parameter inParam = request.getParameterByName(inParamName);
                    parameter.setLinkedParameter(inParam);
                    inParam.setLinkedParameter(parameter);
                    // its in/out parameter, input and output parameter have the same order position.
                    parameter.setParameterIndex(inParam.getParameterIndex());
                }
            }
            if (!definitiveParameterList.contains(parameter.getName())) {
                definitiveParameterList.add(parameter.getName());
            }
            response.addParameter(parameter);
        }
        parameterOrderPosition++;
    }
}
Also used : Message(com.sun.tools.ws.wsdl.document.Message) TWSDLExtensible(com.sun.tools.ws.api.wsdl.TWSDLExtensible) QName(javax.xml.namespace.QName)

Example 9 with Message

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

the class WSDLParser method parseMessage.

private Message parseMessage(TWSDLParserContextImpl context, Definitions definitions, Element e) {
    context.push();
    context.registerNamespaces(e);
    Message message = new Message(definitions, forest.locatorTable.getStartLocation(e), errReceiver);
    String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
    message.setName(name);
    boolean gotDocumentation = false;
    for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext(); ) {
        Element e2 = Util.nextElement(iter);
        if (e2 == null)
            break;
        if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) {
            if (gotDocumentation) {
                Util.fail("parsing.onlyOneDocumentationAllowed", e.getLocalName());
            }
            gotDocumentation = true;
            message.setDocumentation(getDocumentationFor(e2));
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PART)) {
            MessagePart part = parseMessagePart(context, e2);
            message.add(part);
        } else {
        // Ignore any extensibility elements, WS-I BP 1.1 Profiled WSDL 1.1 schema allows extension elements here.
        /*Util.fail(
                    "parsing.invalidElement",
                    e2.getTagName(),
                    e2.getNamespaceURI());
                    */
        }
    }
    context.pop();
    context.fireDoneParsingEntity(WSDLConstants.QNAME_MESSAGE, message);
    return message;
}
Also used : Message(com.sun.tools.ws.wsdl.document.Message) Element(org.w3c.dom.Element) MessagePart(com.sun.tools.ws.wsdl.document.MessagePart) Iterator(java.util.Iterator)

Example 10 with Message

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

the class WSDLModeler method createRpcLitRequestParameters.

private List<Parameter> createRpcLitRequestParameters(Request request, List<String> parameterList, Block block) {
    Message message = getInputMessage();
    S2JJAXBModel jaxbModel = ((RpcLitStructure) block.getType()).getJaxbModel().getS2JJAXBModel();
    List<Parameter> parameters = ModelerUtils.createRpcLitParameters(message, block, jaxbModel, errReceiver);
    // create parameters for header and mime parts
    for (String paramName : parameterList) {
        MessagePart part = message.getPart(paramName);
        if (part == null) {
            continue;
        }
        if (ModelerUtils.isBoundToSOAPHeader(part)) {
            if (parameters == null) {
                parameters = new ArrayList<>();
            }
            QName headerName = part.getDescriptor();
            JAXBType jaxbType = getJAXBType(part);
            Block headerBlock = new Block(headerName, jaxbType, part);
            request.addHeaderBlock(headerBlock);
            Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock);
            if (param != null) {
                parameters.add(param);
            }
        } else if (ModelerUtils.isBoundToMimeContent(part)) {
            if (parameters == null) {
                parameters = new ArrayList<>();
            }
            List<MIMEContent> mimeContents = getMimeContents(info.bindingOperation.getInput(), getInputMessage(), paramName);
            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);
            request.addAttachmentBlock(mimeBlock);
            Parameter param = ModelerUtils.createParameter(part.getName(), type, mimeBlock);
            if (param != null) {
                parameters.add(param);
            }
        } else if (ModelerUtils.isUnbound(part)) {
            if (parameters == null) {
                parameters = new ArrayList<>();
            }
            QName name = part.getDescriptor();
            JAXBType type = getJAXBType(part);
            Block unboundBlock = new Block(name, type, part);
            request.addUnboundBlock(unboundBlock);
            Parameter param = ModelerUtils.createParameter(part.getName(), type, unboundBlock);
            if (param != null) {
                parameters.add(param);
            }
        }
    }
    for (Parameter param : parameters) {
        setCustomizedParameterName(info.portTypeOperation, message, message.getPart(param.getName()), param, false);
    }
    return parameters;
}
Also used : Message(com.sun.tools.ws.wsdl.document.Message) QName(javax.xml.namespace.QName) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel)

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