XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
// Get information about the operation being invoked from the WSDL definition.
// We need this to marshal data correctly
OperationType opElement =
CorbaUtils.getCorbaOperationType(callback.getOperationName(), bus, endpointRef);
if (opElement == null) {
throw new CorbaBindingException("Unable to find operation definition");
}
// Handle the parameters that are given for the operation
List<ParamType> paramTypes = opElement.getParam();
boolean hasOutParamReturn =
addMarshalParams(callback, paramTypes, corbaCtx, objContext,
inputFactory, outputFactory, writer);
// Check to see if we have an input or output message and handle the return type
// appropriately
boolean isInputMessage = (Boolean) mc.get(ObjectMessageContext.MESSAGE_INPUT);
if (!isInputMessage && callback.getWebResult() != null && !hasOutParamReturn) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
writer.write(objContext.getReturn(), callback.getWebResultQName(), evtWriter);
ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
CorbaObjectHandler obj = readObjectFromStax(evtReader,
opElement.getReturn().getIdltype(),
false);
CorbaStreamable streamable = new CorbaStreamable(obj, callback.getWebResultQName());
corbaCtx.getMessage().setStreamableReturn(streamable);
} else if (isInputMessage && callback.getWebResult() != null && !hasOutParamReturn) {
QName retName = callback.getWebResultQName();
QName retIdlType = opElement.getReturn().getIdltype();
CorbaObjectHandler obj =
CorbaHandlerUtils.initializeObjectHandler(orb, retName, retIdlType, typeMaps);
CorbaStreamable streamable = new CorbaStreamable(obj, retName);
corbaCtx.getMessage().setStreamableReturn(streamable);
}