use of org.omg.CORBA.NVList in project cxf by apache.
the class CorbaStreamInInterceptor method prepareDIIArgsList.
protected NVList prepareDIIArgsList(CorbaMessage corbaMsg, BindingOperationInfo boi, CorbaStreamable[] streamables, List<ParamType> paramTypes, CorbaTypeMap map, ORB orb, ServiceInfo service) {
try {
// Build the list of DII arguments, returns, and exceptions
NVList list = orb.create_list(streamables.length);
OperationInfo opInfo = boi.getOperationInfo();
MessageInfo input = opInfo.getInput();
MessageInfo output = opInfo.getOutput();
String inWrapNSUri = null;
String outWrapNSUri = null;
boolean wrap = false;
if (boi.isUnwrappedCapable()) {
wrap = true;
if (input != null) {
inWrapNSUri = getWrappedParamNamespace(input);
if (!CorbaUtils.isElementFormQualified(service, inWrapNSUri)) {
inWrapNSUri = "";
}
}
if (output != null) {
outWrapNSUri = getWrappedParamNamespace(output);
if (!CorbaUtils.isElementFormQualified(service, outWrapNSUri)) {
outWrapNSUri = "";
}
}
}
int inMsgIndex = 0;
int outMsgIndex = 0;
for (int i = 0; i < paramTypes.size(); i++) {
ParamType param = paramTypes.get(i);
QName paramIdlType = param.getIdltype();
QName paramName;
ModeType paramMode = param.getMode();
if ("in".equals(paramMode.value())) {
if (wrap) {
paramName = new QName(inWrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(input, param.getName(), inMsgIndex);
inMsgIndex++;
}
} else {
if (wrap) {
paramName = new QName(outWrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(output, param.getName(), outMsgIndex);
outMsgIndex++;
}
}
CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, paramIdlType, map, service);
streamables[i] = corbaMsg.createStreamableObject(obj, paramName);
Any value = CorbaAnyHelper.createAny(orb, corbaMsg.getExchange().getBus());
if ("in".equals(paramMode.value())) {
streamables[i].setMode(org.omg.CORBA.ARG_IN.value);
streamables[i].getObject().setIntoAny(value, streamables[i], false);
} else if ("out".equals(paramMode.value())) {
streamables[i].setMode(org.omg.CORBA.ARG_OUT.value);
streamables[i].getObject().setIntoAny(value, streamables[i], true);
} else {
streamables[i].setMode(org.omg.CORBA.ARG_INOUT.value);
streamables[i].getObject().setIntoAny(value, streamables[i], false);
}
list.add_value(streamables[i].getName(), value, streamables[i].getMode());
corbaMsg.addStreamableArgument(streamables[i]);
}
return list;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of org.omg.CORBA.NVList in project cxf by apache.
the class CorbaConduit method getArguments.
public NVList getArguments(CorbaMessage message) {
if (orb == null) {
prepareOrb();
}
// Build the list of DII arguments, returns, and exceptions
final NVList list;
if (message.getStreamableArguments() != null) {
CorbaStreamable[] arguments = message.getStreamableArguments();
list = orb.create_list(arguments.length);
for (CorbaStreamable argument : arguments) {
Any value = CorbaAnyHelper.createAny(orb, message.getExchange().getBus());
argument.getObject().setIntoAny(value, argument, true);
list.add_value(argument.getName(), value, argument.getMode());
}
} else {
list = orb.create_list(0);
}
return list;
}
use of org.omg.CORBA.NVList 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();
}*/
}
use of org.omg.CORBA.NVList in project cxf by apache.
the class CorbaMessageTest method testGetCorbaMessageAttributes.
@Test
public void testGetCorbaMessageAttributes() {
CorbaMessage msg = new CorbaMessage(message);
QName param1Name = new QName("param1");
QName param1IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
TypeCode param1TypeCode = orb.get_primitive_tc(TCKind.tk_long);
CorbaPrimitiveHandler param1 = new CorbaPrimitiveHandler(param1Name, param1IdlType, param1TypeCode, null);
CorbaStreamable p1 = msg.createStreamableObject(param1, param1Name);
QName param2Name = new QName("param2");
QName param2IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
TypeCode param2TypeCode = orb.get_primitive_tc(TCKind.tk_string);
CorbaPrimitiveHandler param2 = new CorbaPrimitiveHandler(param2Name, param2IdlType, param2TypeCode, null);
CorbaStreamable p2 = msg.createStreamableObject(param2, param2Name);
msg.addStreamableArgument(p1);
msg.addStreamableArgument(p2);
CorbaStreamable[] arguments = msg.getStreamableArguments();
assertTrue(arguments.length == 2);
assertNotNull(arguments[0]);
assertNotNull(arguments[1]);
QName param3Name = new QName("param3");
QName param3IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
TypeCode param3TypeCode = orb.get_primitive_tc(TCKind.tk_short);
CorbaPrimitiveHandler param3 = new CorbaPrimitiveHandler(param3Name, param3IdlType, param3TypeCode, null);
CorbaStreamable p3 = msg.createStreamableObject(param3, param3Name);
QName param4Name = new QName("param4");
QName param4IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "float", CorbaConstants.NP_WSDL_CORBA);
TypeCode param4TypeCode = orb.get_primitive_tc(TCKind.tk_float);
CorbaPrimitiveHandler param4 = new CorbaPrimitiveHandler(param4Name, param4IdlType, param4TypeCode, null);
CorbaStreamable p4 = msg.createStreamableObject(param4, param4Name);
CorbaStreamable[] args = new CorbaStreamable[2];
args[0] = p3;
args[1] = p4;
msg.setStreamableArguments(args);
arguments = msg.getStreamableArguments();
assertTrue(arguments.length == 4);
assertNotNull(arguments[0]);
assertNotNull(arguments[1]);
assertNotNull(arguments[2]);
assertNotNull(arguments[3]);
NVList list = orb.create_list(2);
Any value = orb.create_any();
value.insert_Streamable(p1);
list.add_value(p1.getName(), value, p1.getMode());
value.insert_Streamable(p2);
list.add_value(p2.getName(), value, p2.getMode());
msg.setList(list);
NVList resultList = msg.getList();
assertTrue(resultList.count() == 2);
QName returnName = new QName("param2");
QName returnIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
TypeCode returnTypeCode = orb.get_primitive_tc(TCKind.tk_boolean);
CorbaPrimitiveHandler returnValue = new CorbaPrimitiveHandler(returnName, returnIdlType, returnTypeCode, null);
CorbaStreamable ret = msg.createStreamableObject(returnValue, returnName);
msg.setStreamableReturn(ret);
CorbaStreamable retVal = msg.getStreamableReturn();
assertNotNull(retVal);
// NEED TO DO TEST FOR EXCEPTIONS
/*Exception ex = new CorbaBindingException("TestException");
msg.s.setException(ex);
Exception msgEx = msg.getException();
assertNotNull(msgEx);
assertEquals(msgEx.getMessage(), ex.getMessage());*/
}
use of org.omg.CORBA.NVList in project cxf by apache.
the class CorbaServerConduitTest method testBuildRequestResult.
@Test
public void testBuildRequestResult() {
NVList list = orb.create_list(0);
CorbaServerConduit conduit = setupCorbaServerConduit(false);
CorbaMessage msg = control.createMock(CorbaMessage.class);
Exchange exchange = control.createMock(Exchange.class);
ServerRequest request = control.createMock(ServerRequest.class);
EasyMock.expect(msg.getExchange()).andReturn(exchange);
EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
EasyMock.expect(exchange.isOneWay()).andReturn(false);
CorbaMessage inMsg = EasyMock.createMock(CorbaMessage.class);
EasyMock.expect(msg.getExchange()).andReturn(exchange);
EasyMock.expect(exchange.getInMessage()).andReturn(inMsg);
EasyMock.expect(inMsg.getList()).andReturn(list);
EasyMock.expect(msg.getStreamableException()).andReturn(null);
EasyMock.expect(msg.getStreamableArguments()).andReturn(null);
EasyMock.expect(msg.getStreamableReturn()).andReturn(null);
control.replay();
conduit.buildRequestResult(msg);
control.verify();
}
Aggregations