Search in sources :

Example 1 with NVList

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

the class CorbaServerConduit method buildRequestResult.

public void buildRequestResult(CorbaMessage msg) {
    Exchange exg = msg.getExchange();
    ServerRequest request = exg.get(ServerRequest.class);
    try {
        if (!exg.isOneWay()) {
            CorbaMessage inMsg = (CorbaMessage) msg.getExchange().getInMessage();
            NVList list = inMsg.getList();
            if (msg.getStreamableException() != null) {
                Any exAny = CorbaAnyHelper.createAny(orb, exg.getBus());
                CorbaStreamable exception = msg.getStreamableException();
                exAny.insert_Streamable(exception);
                request.set_exception(exAny);
                if (msg.getExchange() != null) {
                    msg.getExchange().setOutFaultMessage(msg);
                }
            } else {
                CorbaStreamable[] arguments = msg.getStreamableArguments();
                if (arguments != null) {
                    for (int i = 0; i < arguments.length; ++i) {
                        if (list.item(i).flags() != org.omg.CORBA.ARG_IN.value) {
                            arguments[i].getObject().setIntoAny(list.item(i).value(), arguments[i], true);
                        }
                    }
                }
                CorbaStreamable resultValue = msg.getStreamableReturn();
                if (resultValue != null) {
                    Any resultAny = CorbaAnyHelper.createAny(orb, exg.getBus());
                    resultValue.getObject().setIntoAny(resultAny, resultValue, true);
                    request.set_result(resultAny);
                }
            }
        }
    } catch (java.lang.Exception ex) {
        throw new CorbaBindingException("Exception during buildRequestResult", ex);
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServerRequest(org.omg.CORBA.ServerRequest) NVList(org.omg.CORBA.NVList) Any(org.omg.CORBA.Any)

Example 2 with NVList

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

the class CorbaStreamInInterceptor method handleRequest.

private void handleRequest(Message msg) {
    ORB orb;
    ServiceInfo service;
    CorbaDestination destination;
    if (msg.getDestination() != null) {
        destination = (CorbaDestination) msg.getDestination();
    } else {
        destination = (CorbaDestination) msg.getExchange().getDestination();
    }
    service = destination.getBindingInfo().getService();
    CorbaMessage message = (CorbaMessage) msg;
    Exchange exchange = message.getExchange();
    CorbaTypeMap typeMap = message.getCorbaTypeMap();
    BindingInfo bInfo = destination.getBindingInfo();
    InterfaceInfo info = bInfo.getInterface();
    String opName = exchange.get(String.class);
    Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
    OperationType opType = null;
    BindingOperationInfo bopInfo = null;
    QName opQName = null;
    while (i.hasNext()) {
        bopInfo = i.next();
        if (bopInfo.getName().getLocalPart().equals(opName)) {
            opType = bopInfo.getExtensor(OperationType.class);
            opQName = bopInfo.getName();
            break;
        }
    }
    if (opType == null) {
        throw new RuntimeException("Couldn't find the binding operation for " + opName);
    }
    orb = exchange.get(ORB.class);
    ServerRequest request = exchange.get(ServerRequest.class);
    NVList list = prepareArguments(message, info, opType, opQName, typeMap, destination, service);
    request.arguments(list);
    message.setList(list);
    HandlerIterator paramIterator = new HandlerIterator(message, true);
    final CorbaTypeEventProducer eventProducer;
    BindingMessageInfo msgInfo = bopInfo.getInput();
    boolean wrap = false;
    if (bopInfo.isUnwrappedCapable()) {
        wrap = true;
    }
    if (wrap) {
        // wrapper element around our args
        QName wrapperElementQName = msgInfo.getMessageInfo().getName();
        eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
    } else {
        eventProducer = new ParameterEventProducer(paramIterator, service, orb);
    }
    CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
    message.setContent(XMLStreamReader.class, reader);
}
Also used : CorbaTypeMap(org.apache.cxf.binding.corba.CorbaTypeMap) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) WrappedParameterSequenceEventProducer(org.apache.cxf.binding.corba.types.WrappedParameterSequenceEventProducer) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) QName(javax.xml.namespace.QName) HandlerIterator(org.apache.cxf.binding.corba.types.HandlerIterator) CorbaStreamReader(org.apache.cxf.binding.corba.runtime.CorbaStreamReader) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Exchange(org.apache.cxf.message.Exchange) ParameterEventProducer(org.apache.cxf.binding.corba.types.ParameterEventProducer) CorbaDestination(org.apache.cxf.binding.corba.CorbaDestination) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) CorbaTypeEventProducer(org.apache.cxf.binding.corba.types.CorbaTypeEventProducer) ServerRequest(org.omg.CORBA.ServerRequest) NVList(org.omg.CORBA.NVList) ORB(org.omg.CORBA.ORB)

Example 3 with NVList

use of org.omg.CORBA.NVList 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;
    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 4 with NVList

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

the class CorbaConduitTest method testBuildArguments.

@Test
public void testBuildArguments() throws Exception {
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    Exchange exchange = new ExchangeImpl();
    exchange.put(Bus.class, bus);
    message.setExchange(exchange);
    CorbaStreamable[] arguments = new CorbaStreamable[1];
    QName objName = new QName("object");
    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);
    arguments[0] = arg;
    arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
    CorbaConduit conduit = setupCorbaConduit(false);
    NVList list = conduit.getArguments(message);
    assertNotNull("list should not be null", list != null);
    message.setStreamableArguments(arguments);
    NVList listArgs = conduit.getArguments(message);
    assertNotNull("listArgs should not be null", listArgs != null);
    assertNotNull("listArgs Item should not be null", listArgs.item(0) != null);
    assertEquals("Name should be equal", listArgs.item(0).name(), "object");
    assertEquals("flags should be 2", listArgs.item(0).flags(), 2);
    assertNotNull("Any Value should not be null", listArgs.item(0).value() != null);
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NVList(org.omg.CORBA.NVList) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 5 with NVList

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

the class CorbaUtils method nvListFromStreamables.

public static NVList nvListFromStreamables(ORB orb, CorbaStreamable[] streamables) {
    final NVList list;
    if (streamables != null && streamables.length > 0) {
        list = orb.create_list(streamables.length);
        for (CorbaStreamable streamable : streamables) {
            Any value = orb.create_any();
            value.insert_Streamable(streamable);
            list.add_value(streamable.getName(), value, streamable.getMode());
        }
    } else {
        list = orb.create_list(0);
    }
    return list;
}
Also used : CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) NVList(org.omg.CORBA.NVList) Any(org.omg.CORBA.Any)

Aggregations

NVList (org.omg.CORBA.NVList)12 QName (javax.xml.namespace.QName)7 Any (org.omg.CORBA.Any)7 Exchange (org.apache.cxf.message.Exchange)6 Test (org.junit.Test)6 ServerRequest (org.omg.CORBA.ServerRequest)5 TypeCode (org.omg.CORBA.TypeCode)5 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)4 CorbaStreamableImpl (org.apache.cxf.binding.corba.runtime.CorbaStreamableImpl)2 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)2 Message (org.apache.cxf.message.Message)2 MessageImpl (org.apache.cxf.message.MessageImpl)2 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)2 ExceptionList (org.omg.CORBA.ExceptionList)2 NamedValue (org.omg.CORBA.NamedValue)2 Request (org.omg.CORBA.Request)2 IOException (java.io.IOException)1 CorbaDestination (org.apache.cxf.binding.corba.CorbaDestination)1