use of org.omg.CORBA.ExceptionList 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.ExceptionList in project cxf by apache.
the class CorbaConduitTest method testBuildExceptionListWithExceptions.
@Test
public void testBuildExceptionListWithExceptions() throws Exception {
CorbaConduit conduit = setupCorbaConduit(false);
Message msg = new MessageImpl();
CorbaMessage message = new CorbaMessage(msg);
TestUtils testUtils = new TestUtils();
CorbaDestination destination = testUtils.getExceptionTypesTestDestination();
EndpointInfo endpointInfo2 = destination.getEndPointInfo();
QName name = new QName("http://schemas.apache.org/idl/except", "review_data", "");
BindingOperationInfo bInfo = destination.getBindingInfo().getOperation(name);
OperationType opType = bInfo.getExtensor(OperationType.class);
CorbaTypeMap typeMap = null;
List<TypeMappingType> corbaTypes = endpointInfo2.getService().getDescription().getExtensors(TypeMappingType.class);
if (corbaTypes != null) {
typeMap = CorbaUtils.createCorbaTypeMap(corbaTypes);
}
ExceptionList exList = conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMap), message, opType);
assertNotNull("ExceptionList is not null", exList != null);
assertNotNull("TypeCode is not null", exList.item(0) != null);
assertEquals("ID should be equal", exList.item(0).id(), "IDL:BadRecord:1.0");
assertEquals("ID should be equal", exList.item(0).name(), "BadRecord");
assertEquals("ID should be equal", exList.item(0).member_count(), 2);
assertEquals("ID should be equal", exList.item(0).member_name(0), "reason");
assertNotNull("Member type is not null", exList.item(0).member_type(0) != null);
}
use of org.omg.CORBA.ExceptionList in project cxf by apache.
the class CorbaConduit method getExceptionList.
public ExceptionList getExceptionList(Map<TypeCode, RaisesType> exceptions, CorbaMessage message, OperationType opType) {
if (orb == null) {
prepareOrb();
}
// Get the typecodes for the exceptions this operation can throw.
// These are defined in the operation definition from WSDL.
ExceptionList exList = orb.create_exception_list();
if (exceptions != null) {
Object[] tcs = null;
tcs = exceptions.keySet().toArray();
for (int i = 0; i < exceptions.size(); ++i) {
exList.add((TypeCode) tcs[i]);
}
}
return exList;
}
use of org.omg.CORBA.ExceptionList in project cxf by apache.
the class CorbaConduitTest method testBuildExceptionListEmpty.
@Test
public void testBuildExceptionListEmpty() throws Exception {
CorbaConduit conduit = setupCorbaConduit(false);
Message msg = new MessageImpl();
CorbaMessage message = new CorbaMessage(msg);
OperationType opType = new OperationType();
opType.setName("review_data");
ExceptionList exList = conduit.getExceptionList(conduit.getOperationExceptions(opType, null), message, opType);
assertNotNull("ExcepitonList is not null", exList != null);
assertEquals("The list should be empty", exList.count(), 0);
}
use of org.omg.CORBA.ExceptionList 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