Search in sources :

Example 36 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLParameter method getSchemaTypeName.

private static QName getSchemaTypeName(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType, XmlSchemaAnnotation annotation, QName typeName, boolean nill) throws Exception {
    QName idltype = null;
    CorbaType corbaTypeImpl = null;
    corbaTypeImpl = wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType, typeName, null, annotation, false);
    if (corbaTypeImpl == null) {
        throw new Exception("Couldn't convert schema type to corba type : " + typeName);
    }
    if (nill) {
        QName qname = corbaTypeImpl.getQName();
        idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
    } else {
        idltype = corbaTypeImpl.getQName();
    }
    return idltype;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName)

Example 37 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLParameter method getIdlType.

private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType, QName typeName, boolean nill) throws Exception {
    QName idltype = null;
    CorbaType corbaTypeImpl = null;
    if (schemaType == null) {
        corbaTypeImpl = (CorbaType) WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
        if (nill) {
            QName qname = corbaTypeImpl.getQName();
            idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
        } else {
            if (corbaTypeImpl == null) {
                XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
                XmlSchemaAnnotation annotation = null;
                if (schemaObj instanceof XmlSchemaElement) {
                    XmlSchemaElement el = (XmlSchemaElement) schemaObj;
                    schemaType = el.getSchemaType();
                    annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
                }
                idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
            } else {
                idltype = corbaTypeImpl.getQName();
            }
        }
    } else {
        // We need to get annotation information for the schema type we are
        // about to pass in.
        // This is used to produce the correct object reference type.
        XmlSchemaElement schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
        XmlSchemaAnnotation annotation = null;
        if (schemaObj != null) {
            annotation = schemaObj.getAnnotation();
        }
        idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
    }
    return idltype;
}
Also used : XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

Example 38 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaBinding method addCorbaTypes.

private void addCorbaTypes(XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaType> objs = xmlSchemaTypes.getSchemaTypes();
    CorbaType corbaTypeImpl = null;
    for (XmlSchemaType type : objs.values()) {
        boolean anonymous = WSDLTypes.isAnonymous(type.getName());
        corbaTypeImpl = helper.convertSchemaToCorbaType(type, type.getQName(), null, null, anonymous);
        if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        }
    }
    addCorbaElements(corbaTypeImpl, xmlSchemaTypes);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 39 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType 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;
    XmlSchemaType schemaType = 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();
    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)

Example 40 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaBinding method addCorbaOperationExtElement.

private void addCorbaOperationExtElement(BindingOperation bo, Operation op) throws Exception {
    OperationType operationType = null;
    try {
        operationType = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException wse) {
        LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
        throw new Exception(LOG.toString(), wse);
    }
    operationType.setName(op.getName());
    List<ParamType> params = new ArrayList<>();
    List<ArgType> returns = new ArrayList<>();
    wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);
    for (ParamType paramtype : params) {
        operationType.getParam().add(paramtype);
    }
    for (ArgType retType : returns) {
        operationType.setReturn(retType);
    }
    Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
    for (Fault fault : faults) {
        RaisesType raisestype = new RaisesType();
        CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
        if (extype != null) {
            raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
            operationType.getRaises().add(raisestype);
        }
    }
    bo.addExtensibilityElement((ExtensibilityElement) operationType);
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) WSDLException(javax.wsdl.WSDLException) ArrayList(java.util.ArrayList) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Aggregations

CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)71 QName (javax.xml.namespace.QName)44 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)22 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)13 AST (antlr.collections.AST)9 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)8 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)8 Test (org.junit.Test)8 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)7 Alias (org.apache.cxf.binding.corba.wsdl.Alias)6 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)6 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)6 Struct (org.apache.cxf.binding.corba.wsdl.Struct)6 Union (org.apache.cxf.binding.corba.wsdl.Union)6 File (java.io.File)5 Definition (javax.wsdl.Definition)5 ArrayList (java.util.ArrayList)4 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)4 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4