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");
}
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));
}
}
}
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;
}
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();
}*/
}
Aggregations