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);
}
}
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);
}
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));
}
}
}
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);
}
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;
}
Aggregations