Search in sources :

Example 31 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaUtilsTest method testFloatTypeCode.

@Test
public void testFloatTypeCode() {
    QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "float", "corba");
    TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
    assertNotNull(tc);
    assertTrue(tc.kind().value() == TCKind._tk_float);
    assertTrue(CorbaUtils.isPrimitiveIdlType(type));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 32 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaUtilsTest method testWCharTypeCode.

@Test
public void testWCharTypeCode() {
    QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "wchar", "corba");
    TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
    assertNotNull(tc);
    assertTrue(tc.kind().value() == TCKind._tk_wchar);
    assertTrue(CorbaUtils.isPrimitiveIdlType(type));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 33 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaUtilsTest method testShortTypeCode.

@Test
public void testShortTypeCode() {
    QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "short", "corba");
    TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
    assertNotNull(tc);
    assertTrue(tc.kind().value() == TCKind._tk_short);
    assertTrue(CorbaUtils.isPrimitiveIdlType(type));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 34 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaConduit method buildRequest.

public void buildRequest(CorbaMessage message, OperationType opType) throws Exception {
    ServiceInfo service = message.getExchange().getEndpoint().getEndpointInfo().getService();
    NVList nvlist = getArguments(message);
    NamedValue ret = getReturn(message);
    Map<TypeCode, RaisesType> exceptions = getOperationExceptions(opType, typeMap);
    ExceptionList exList = getExceptionList(exceptions, message, opType);
    Request request = getRequest(message, opType.getName(), nvlist, ret, exList);
    if (request == null) {
        throw new CorbaBindingException("Couldn't build the corba request");
    }
    Exception ex = null;
    try {
        request.invoke();
        ex = request.env().exception();
    } catch (SystemException sysex) {
        ex = sysex;
    }
    if (ex != null) {
        if (ex instanceof SystemException) {
            message.setContent(Exception.class, new Fault(ex));
            message.setSystemException((SystemException) ex);
            return;
        }
        if (ex instanceof UnknownUserException) {
            UnknownUserException userEx = (UnknownUserException) ex;
            Any except = userEx.except;
            RaisesType raises = exceptions.get(except.type());
            if (raises == null) {
                throw new CorbaBindingException("Couldn't find the exception type code to unmarshall");
            }
            QName elName = new QName("", raises.getException().getLocalPart());
            CorbaObjectHandler handler = CorbaHandlerUtils.initializeObjectHandler(orb, elName, raises.getException(), typeMap, service);
            CorbaStreamable exStreamable = message.createStreamableObject(handler, elName);
            exStreamable._read(except.create_input_stream());
            message.setStreamableException(exStreamable);
            message.setContent(Exception.class, new Fault(userEx));
        } else {
            message.setContent(Exception.class, new Fault(ex));
        }
    }
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Request(org.omg.CORBA.Request) UnknownUserException(org.omg.CORBA.UnknownUserException) ExceptionList(org.omg.CORBA.ExceptionList) NamedValue(org.omg.CORBA.NamedValue) Fault(org.apache.cxf.interceptor.Fault) Any(org.omg.CORBA.Any) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException) UnknownUserException(org.omg.CORBA.UnknownUserException) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) SystemException(org.omg.CORBA.SystemException) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) NVList(org.omg.CORBA.NVList)

Example 35 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class SystemExceptionHelper method _type.

public TypeCode _type() {
    if (typeCode == null) {
        ORB orb = ORB.init();
        StructMember[] smBuf = new StructMember[2];
        TypeCode minortc = orb.get_primitive_tc(TCKind.tk_long);
        smBuf[0] = new StructMember("minor", minortc, null);
        String[] csLabels = { "COMPLETED_YES", "COMPLETED_NO", "COMPLETED_MAYBE" };
        TypeCode completedtc = orb.create_enum_tc("IDL:omg.org/CORBA/CompletionStatus:1.0", "CompletionStatus", csLabels);
        smBuf[1] = new StructMember("completed", completedtc, null);
        String id;
        String name;
        if (value == null) {
            name = "SystemException";
            id = "IDL:omg.org/CORBA/SystemException:1.0";
        } else {
            String className = value.getClass().getName();
            name = className.substring(className.lastIndexOf('.') + 1);
            id = "IDL:omg.org/CORBA/" + name + ":1.0";
        }
        typeCode = orb.create_exception_tc(id, name, smBuf);
    }
    return typeCode;
}
Also used : TypeCode(org.omg.CORBA.TypeCode) StructMember(org.omg.CORBA.StructMember) ORB(org.omg.CORBA.ORB)

Aggregations

TypeCode (org.omg.CORBA.TypeCode)69 QName (javax.xml.namespace.QName)49 Test (org.junit.Test)44 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)18 InputStream (org.omg.CORBA.portable.InputStream)15 OutputStream (org.omg.CORBA.portable.OutputStream)14 StructMember (org.omg.CORBA.StructMember)9 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)6 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)6 Any (org.omg.CORBA.Any)6 NVList (org.omg.CORBA.NVList)6 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)5 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4 Enum (org.apache.cxf.binding.corba.wsdl.Enum)4 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)4 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)4 IOException (java.io.IOException)3 Alias (org.apache.cxf.binding.corba.wsdl.Alias)3