Search in sources :

Example 41 with Message

use of javax.wsdl.Message in project cxf by apache.

the class WSDLASTVisitor method getLogicalDefinition.

// Gets the logical definition for a file - an import will be added for the
// schema types if -T is used and a separate schema file generated.
// if -n is used an import will be added for the schema types and no types generated.
private Definition getLogicalDefinition(String schemaFilename, Writer schemaWriter) throws WSDLException, JAXBException, Exception {
    Definition def = manager.createWSDLDefinition(targetNamespace);
    // checks for -T option.
    if (schemaFilename != null) {
        writeSchemaDefinition(definition, schemaWriter);
        manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), schemaFilename);
    } else {
        // checks for -n option
        if (importSchemaFilename == null) {
            Types types = definition.getTypes();
            def.setTypes(types);
        } else {
            manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), importSchemaFilename);
        }
    }
    Collection<PortType> portTypes = CastUtils.cast(definition.getAllPortTypes().values());
    for (PortType port : portTypes) {
        def.addPortType(port);
    }
    Collection<Message> messages = CastUtils.cast(definition.getMessages().values());
    for (Message msg : messages) {
        def.addMessage(msg);
    }
    Collection<String> namespaces = CastUtils.cast(definition.getNamespaces().values());
    for (String namespace : namespaces) {
        String prefix = definition.getPrefix(namespace);
        if (!"corba".equals(prefix)) {
            def.addNamespace(prefix, namespace);
        } else {
            def.removeNamespace(prefix);
        }
    }
    Collection<Import> imports = CastUtils.cast(definition.getImports().values());
    for (Import importType : imports) {
        def.addImport(importType);
    }
    def.setDocumentationElement(definition.getDocumentationElement());
    def.setDocumentBaseURI(definition.getDocumentBaseURI());
    return def;
}
Also used : Types(javax.wsdl.Types) Import(javax.wsdl.Import) Message(javax.wsdl.Message) Definition(javax.wsdl.Definition) PortType(javax.wsdl.PortType)

Example 42 with Message

use of javax.wsdl.Message in project cxf by apache.

the class WSDLParameter method processWrappedInputParams.

private void processWrappedInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
    Input input = operation.getInput();
    if (input != null) {
        Message msg = input.getMessage();
        Part part = (Part) msg.getOrderedParts(null).iterator().next();
        XmlSchemaElement el = getElement(part, xmlSchemaList);
        if (el == null) {
            return;
        }
        XmlSchemaComplexType schemaType = null;
        if (el.getSchemaType() != null) {
            schemaType = (XmlSchemaComplexType) el.getSchemaType();
        }
        XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
        if (seq != null) {
            for (XmlSchemaSequenceMember seqItem : seq.getItems()) {
                if (seqItem instanceof XmlSchemaElement) {
                    el = (XmlSchemaElement) seqItem;
                    // REVISIT, handle element ref's?
                    QName typeName = el.getSchemaTypeName();
                    if (typeName == null) {
                        typeName = el.getQName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName, el.isNillable());
                    ParamType paramtype = createParam(wsdlToCorbaBinding, "in", el.getQName().getLocalPart(), idltype);
                    if (paramtype != null) {
                        inputs.add(paramtype);
                    }
                }
            }
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Input(javax.wsdl.Input) Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 43 with Message

use of javax.wsdl.Message in project cxf by apache.

the class WSDLParameter method isWrappedOperation.

private boolean isWrappedOperation(Operation op, SchemaCollection xmlSchemaList) throws Exception {
    Message inputMessage = op.getInput().getMessage();
    Message outputMessage = null;
    if (op.getOutput() != null) {
        outputMessage = op.getOutput().getMessage();
    }
    boolean passedRule = true;
    // input message must exist
    if (inputMessage == null || inputMessage.getParts().size() != 1 || (outputMessage != null && outputMessage.getParts().size() > 1)) {
        passedRule = false;
    }
    if (!passedRule) {
        return false;
    }
    XmlSchemaElement inputEl = null;
    XmlSchemaElement outputEl = null;
    // RULE No.2:
    // The input message part refers to a global element decalration whose
    // localname
    // is equal to the operation name
    Part inputPart = (Part) inputMessage.getParts().values().iterator().next();
    if (inputPart.getElementName() == null) {
        passedRule = false;
    } else {
        QName inputElementName = inputPart.getElementName();
        inputEl = getElement(inputPart, xmlSchemaList);
        if (inputEl == null || !op.getName().equals(inputElementName.getLocalPart())) {
            passedRule = false;
        }
    }
    if (!passedRule) {
        return false;
    }
    // The output message part refers to a global element declaration
    if (outputMessage != null && outputMessage.getParts().size() == 1) {
        Part outputPart = (Part) outputMessage.getParts().values().iterator().next();
        if (outputPart != null) {
            if ((outputPart.getElementName() == null) || getElement(outputPart, xmlSchemaList) == null) {
                passedRule = false;
            } else {
                outputEl = getElement(outputPart, xmlSchemaList);
            }
        }
    }
    if (!passedRule) {
        return false;
    }
    if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType xsct = (XmlSchemaComplexType) inputEl.getSchemaType();
        if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
            passedRule = false;
        }
    } else {
        passedRule = false;
    }
    if (!passedRule) {
        return false;
    }
    if (outputMessage != null) {
        if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
            XmlSchemaComplexType xsct = (XmlSchemaComplexType) outputEl.getSchemaType();
            if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
                passedRule = false;
            }
        } else {
            passedRule = false;
        }
    }
    return passedRule;
}
Also used : Message(javax.wsdl.Message) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Part(javax.wsdl.Part) QName(javax.xml.namespace.QName) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 44 with Message

use of javax.wsdl.Message in project tesb-studio-se by Talend.

the class PublishMetadataRunnable method getAllPaths.

@SuppressWarnings("unchecked")
private Collection<String> getAllPaths() throws URISyntaxException {
    final Set<String> paths = new HashSet<String>();
    final Set<QName> portTypes = new HashSet<QName>();
    final Set<QName> alreadyCreated = new HashSet<QName>();
    for (Binding binding : (Collection<Binding>) wsdlDefinition.getAllBindings().values()) {
        final QName portType = binding.getPortType().getQName();
        if (portTypes.add(portType)) {
            for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
                Operation oper = operation.getOperation();
                Input inDef = oper.getInput();
                if (inDef != null) {
                    Message inMsg = inDef.getMessage();
                    addParamsToPath(portType, oper, inMsg, paths, alreadyCreated);
                }
                Output outDef = oper.getOutput();
                if (outDef != null) {
                    Message outMsg = outDef.getMessage();
                    addParamsToPath(portType, oper, outMsg, paths, alreadyCreated);
                }
                for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
                    Message faultMsg = fault.getMessage();
                    addParamsToPath(portType, oper, faultMsg, paths, alreadyCreated);
                }
            }
        }
    }
    return paths;
}
Also used : Binding(javax.wsdl.Binding) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingOperation(javax.wsdl.BindingOperation) Input(javax.wsdl.Input) Output(javax.wsdl.Output) Collection(java.util.Collection) HashSet(java.util.HashSet)

Example 45 with Message

use of javax.wsdl.Message in project pentaho-kettle by pentaho.

the class WsdlOpFaultList method getFault.

/**
 * Create a WsdlOpFault from the Fault.
 *
 * @param fault
 *          Fault to process.
 * @return WsdlOpFault Result of processing.
 */
@SuppressWarnings("unchecked")
private WsdlOpFault getFault(Fault fault) throws KettleStepException {
    Message m = fault.getMessage();
    // a fault should only have one message part.
    Map<?, Part> partMap = m.getParts();
    if (partMap.size() != 1) {
        throw new IllegalArgumentException("Invalid part count for fault!!");
    }
    Part faultPart = partMap.values().iterator().next();
    boolean complexType = false;
    // type of fault is specified either in Part's type or element attribute.
    QName type = faultPart.getTypeName();
    if (type == null) {
        type = faultPart.getElementName();
        Element schemaElement = _wsdlTypes.findNamedElement(type);
        type = _wsdlTypes.getTypeQName(schemaElement.getAttribute("type"));
        complexType = true;
    }
    return new WsdlOpFault(fault.getName(), type, complexType, _wsdlTypes);
}
Also used : Message(javax.wsdl.Message) Part(javax.wsdl.Part) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element)

Aggregations

Message (javax.wsdl.Message)45 Part (javax.wsdl.Part)26 QName (javax.xml.namespace.QName)25 Operation (javax.wsdl.Operation)22 Input (javax.wsdl.Input)20 BindingOperation (javax.wsdl.BindingOperation)18 Output (javax.wsdl.Output)16 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)9 Map (java.util.Map)8 Binding (javax.wsdl.Binding)8 PortType (javax.wsdl.PortType)8 HashMap (java.util.HashMap)7 BindingInput (javax.wsdl.BindingInput)7 Fault (javax.wsdl.Fault)7 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)7 ArrayList (java.util.ArrayList)6 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)6 BindingOutput (javax.wsdl.BindingOutput)5 Test (org.junit.Test)5 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)4