Search in sources :

Example 1 with NamedValue

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

the class CorbaConduitTest method testBuildReturn.

@Test
public void testBuildReturn() throws Exception {
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    QName objName = new QName("returnName");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable arg = message.createStreamableObject(obj1, objName);
    CorbaConduit conduit = setupCorbaConduit(false);
    NamedValue ret = conduit.getReturn(message);
    assertNotNull("Return should not be null", ret != null);
    assertEquals("name should be equal", ret.name(), "return");
    message.setStreamableReturn(arg);
    NamedValue ret2 = conduit.getReturn(message);
    assertNotNull("Return2 should not be null", ret2 != null);
    assertEquals("name should be equal", ret2.name(), "returnName");
}
Also used : CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NamedValue(org.omg.CORBA.NamedValue) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 2 with NamedValue

use of org.omg.CORBA.NamedValue 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 3 with NamedValue

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

the class CorbaConduit method getReturn.

public NamedValue getReturn(CorbaMessage message) {
    if (orb == null) {
        prepareOrb();
    }
    CorbaStreamable retVal = message.getStreamableReturn();
    NamedValue ret = null;
    if (retVal != null) {
        Any returnAny = CorbaAnyHelper.createAny(orb);
        retVal.getObject().setIntoAny(returnAny, retVal, false);
        ret = orb.create_named_value(retVal.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
    } else {
        // for some reason, some ORBs do not like to
        // have a null NamedValue return value. Create this 'empty'
        // one if a void return type is used.
        ret = orb.create_named_value("return", orb.create_any(), org.omg.CORBA.ARG_OUT.value);
    }
    return ret;
}
Also used : NamedValue(org.omg.CORBA.NamedValue) Any(org.omg.CORBA.Any)

Example 4 with NamedValue

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

the class CorbaConduitTest method testInvoke.

@Test
public void testInvoke() throws Exception {
    CorbaConduit conduit = setupCorbaConduit(false);
    // CorbaMessage message = new CorbaMessage(msg);
    CorbaMessage message = control.createMock(CorbaMessage.class);
    /*String opName = "GreetMe";
        NVList nvlist = (NVList)orb.create_list(0);

        Request request = conduit.getRequest(message, "GreetMe", nvlist, null, null);
        request.invoke();
        */
    org.omg.CORBA.Object obj = control.createMock(org.omg.CORBA.Object.class);
    EasyMock.expect(message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT)).andReturn(obj);
    // msg.put(CorbaConstants.CORBA_ENDPOINT_OBJECT, obj);
    Request r = control.createMock(Request.class);
    NVList nvList = orb.create_list(0);
    NamedValue ret = control.createMock(NamedValue.class);
    ExceptionList exList = control.createMock(ExceptionList.class);
    EasyMock.expect(obj._create_request((Context) EasyMock.anyObject(), EasyMock.eq("greetMe"), EasyMock.isA(NVList.class), EasyMock.isA(NamedValue.class), EasyMock.isA(ExceptionList.class), EasyMock.isA(ContextList.class)));
    EasyMock.expectLastCall().andReturn(r);
    r.invoke();
    EasyMock.expectLastCall();
    control.replay();
    Request request = conduit.getRequest(message, "greetMe", nvList, ret, exList);
    request.invoke();
    control.verify();
/* try {
                ContextList ctxList = orb.create_context_list();
                Context ctx = orb.get_default_context();
                org.omg.CORBA.Object targetObj = (org.omg.CORBA.Object)message
                    .get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
                Request request = targetObj._create_request(ctx, opName, list, ret, exList, ctxList);
                request.invoke();

            } catch (java.lang.Exception ex) {
                ex.printStackTrace();
            }*/
}
Also used : Context(org.omg.CORBA.Context) Request(org.omg.CORBA.Request) ExceptionList(org.omg.CORBA.ExceptionList) NamedValue(org.omg.CORBA.NamedValue) NVList(org.omg.CORBA.NVList) Test(org.junit.Test)

Aggregations

NamedValue (org.omg.CORBA.NamedValue)4 QName (javax.xml.namespace.QName)2 Test (org.junit.Test)2 Any (org.omg.CORBA.Any)2 ExceptionList (org.omg.CORBA.ExceptionList)2 NVList (org.omg.CORBA.NVList)2 Request (org.omg.CORBA.Request)2 TypeCode (org.omg.CORBA.TypeCode)2 IOException (java.io.IOException)1 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)1 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)1 RaisesType (org.apache.cxf.binding.corba.wsdl.RaisesType)1 Fault (org.apache.cxf.interceptor.Fault)1 Message (org.apache.cxf.message.Message)1 MessageImpl (org.apache.cxf.message.MessageImpl)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1 Context (org.omg.CORBA.Context)1 SystemException (org.omg.CORBA.SystemException)1 UnknownUserException (org.omg.CORBA.UnknownUserException)1