}
public void handleMessage(Message msg) {
CorbaMessage message = (CorbaMessage) msg;
Exchange exchange = message.getExchange();
CorbaDestination destination;
Fault faultEx = null;
if (message.getDestination() != null) {
destination = (CorbaDestination)message.getDestination();
} else {
destination = (CorbaDestination)exchange.getDestination();
}
orb = (ORB) message.get(CorbaConstants.ORB);
if (orb == null) {
orb = (ORB) exchange.get(ORB.class);
}
DataWriter<XMLStreamWriter> writer = getDataWriter(message);
Throwable ex = message.getContent(Exception.class);
// JCGS. If the cause is not available I can only continue if the exception
// is a Fault instance and contains a detail object.
if (ex.getCause() == null) {
if ((ex instanceof Fault) && (((Fault)ex).getDetail() != null)) {
faultEx = (Fault) ex;
} else {
throw new CorbaBindingException(ex);
}
} else {
ex = ex.getCause();
}
if (ex instanceof InvocationTargetException) {
ex = ex.getCause();
}
if (ex instanceof SystemException) {
setSystemException(message, ex, destination);
return;
}
String exClassName = null;
if (faultEx == null) {
//REVISIT, we should not have to depend on WebFault annotation
//Try changing the fault name to the proper mangled java exception classname.
WebFault fault = ex.getClass().getAnnotation(WebFault.class);
if (fault == null) {
throw new CorbaBindingException(ex);
}
exClassName = fault.name();
} else {
//JCGS: exClassName to be set to the exception name
Element faultElement = (Element) faultEx.getDetail().getFirstChild();
exClassName = faultElement.getLocalName();
}
// Get information about the operation being invoked from the WSDL
// definition.
// We need this to marshal data correctly
BindingInfo bInfo = destination.getBindingInfo();
String opName = message.getExchange().get(String.class);
Iterator<BindingOperationInfo> iter = bInfo.getOperations().iterator();