Search in sources :

Example 46 with Part

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

the class ServiceWSDLBuilderTest method testNoBodyParts.

@Test
public void testNoBodyParts() throws Exception {
    setupWSDL(NO_BODY_PARTS_WSDL_PATH);
    QName messageName = new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1Request");
    Message message = newDef.getMessage(messageName);
    Part part = message.getPart("mimeAttachment");
    assertNotNull(part.getTypeName());
}
Also used : Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) Test(org.junit.Test)

Example 47 with Part

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

the class ServiceWSDLBuilder method buildMessage.

protected void buildMessage(Message message, AbstractMessageContainer messageContainer, final Definition def) {
    addDocumentation(message, messageContainer.getMessageDocumentation());
    message.setQName(messageContainer.getName());
    message.setUndefined(false);
    def.addMessage(message);
    List<MessagePartInfo> messageParts = messageContainer.getMessageParts();
    for (MessagePartInfo messagePartInfo : messageParts) {
        final Part messagePart = def.createPart();
        messagePart.setName(messagePartInfo.getName().getLocalPart());
        if (messagePartInfo.isElement()) {
            messagePart.setElementName(messagePartInfo.getElementQName());
            addNamespace(messagePartInfo.getElementQName().getNamespaceURI(), def);
        } else if (messagePartInfo.getTypeQName() != null) {
            messagePart.setTypeName(messagePartInfo.getTypeQName());
            addNamespace(messagePartInfo.getTypeQName().getNamespaceURI(), def);
        }
        message.addPart(messagePart);
    }
}
Also used : Part(javax.wsdl.Part) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 48 with Part

use of javax.wsdl.Part 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 49 with Part

use of javax.wsdl.Part 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 50 with Part

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

the class WSDLToCorbaBinding method convertFaultToCorbaType.

private CorbaType convertFaultToCorbaType(XmlSchema xmlSchema, Fault fault) throws Exception {
    org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
    Iterator<Part> parts = CastUtils.cast(fault.getMessage().getParts().values().iterator());
    if (!parts.hasNext()) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    Part part = parts.next();
    XmlSchemaType schemaType = helper.lookUpType(part);
    if (schemaType != null) {
        QName name = schemaType.getQName();
        if (name == null) {
            name = part.getElementName();
        }
        if (!helper.isSchemaTypeException(schemaType)) {
            corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
            String faultName = fault.getMessage().getQName().getLocalPart();
            int pos = faultName.indexOf("_exception.");
            if (pos != -1) {
                faultName = faultName.substring(pos + 11);
                faultName = faultName + "Exception";
            }
            QName faultMsgName = helper.createQNameCorbaNamespace(faultName);
            corbaex.setName(faultName);
            corbaex.setQName(faultMsgName);
            CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, name, null, null, false);
            if (corbaTypeImpl != null) {
                MemberType member = new MemberType();
                member.setName(corbaTypeImpl.getQName().getLocalPart());
                member.setIdltype(corbaTypeImpl.getQName());
                if (corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified()) {
                    member.setQualified(true);
                }
                corbaex.getMember().add(member);
            }
        } else {
            corbaex = createCorbaException(name, schemaType);
        }
    }
    if (schemaType == null) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " INCORRECT_FAULT_MSG.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    if (corbaex == null) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    // Set the repository ID for Exception
    // add to CorbaTypeMapping
    String repoId = WSDLToCorbaHelper.REPO_STRING + corbaex.getName().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION;
    corbaex.setRepositoryID(repoId);
    CorbaType corbaTypeImpl = corbaex;
    if (!helper.isDuplicate(corbaTypeImpl)) {
        CorbaType dup = helper.isDuplicateException(corbaTypeImpl);
        if (dup != null) {
            typeMappingType.getStructOrExceptionOrUnion().remove(dup);
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        } else {
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        }
    }
    return corbaex;
}
Also used : QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) Part(javax.wsdl.Part)

Aggregations

Part (javax.wsdl.Part)53 QName (javax.xml.namespace.QName)30 Message (javax.wsdl.Message)25 Operation (javax.wsdl.Operation)15 BindingOperation (javax.wsdl.BindingOperation)13 Input (javax.wsdl.Input)12 ArrayList (java.util.ArrayList)8 Output (javax.wsdl.Output)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 OMElement (org.apache.axiom.om.OMElement)7 Element (org.w3c.dom.Element)7 Binding (javax.wsdl.Binding)6 OpenEJBException (org.apache.openejb.OpenEJBException)6 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)6 Fault (javax.wsdl.Fault)5 Port (javax.wsdl.Port)5 Service (javax.wsdl.Service)5 MIMEPart (javax.wsdl.extensions.mime.MIMEPart)5 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)5