call.registerTypeMapping(ServiceDataCargo.class, serviceDataCargoTypeQName,
new BinarySerializerFactory(mUseAttachments), new BinaryDeserializerFactory());
// extract data from CAS to prepare for binary serialization
// (do not send process trace)
ServiceDataCargo dataCargo = new ServiceDataCargo(aCAS, null);
// call service
Object result = call.invoke(new Object[] { dataCargo, null });
// System.out.println("Got return value of class: " + result.getClass().getName()); //DEBUG
ServiceDataCargo resultCargo = null;
// if result was attachment, extract data and deserialize
if (result instanceof AttachmentPart) {
ObjectInputStream objStream = null;
try {
DataHandler dataHandler = AttachmentUtils
.getActivationDataHandler((AttachmentPart) result);
Object content = dataHandler.getContent();
// System.out.println(content.getClass().getName());
objStream = new ObjectInputStream((InputStream) content);
resultCargo = (ServiceDataCargo) objStream.readObject();
} catch (IOException e) {
throw new ResourceServiceException(e);
} catch (ClassNotFoundException e) {
throw new ResourceServiceException(e);
} finally {
if (objStream != null) {
try {
objStream.close();
} catch (IOException e) {
throw new ResourceServiceException(e);
}
}
}
} else if (result instanceof ServiceDataCargo) // direct return
{
resultCargo = (ServiceDataCargo) result;
} else {
throw new ResourceServiceException(
ResourceServiceException.UNEXPECTED_SERVICE_RETURN_VALUE_TYPE, new Object[] {
ServiceDataCargo.class.getName(),
resultCargo == null ? "null" : resultCargo.getClass().getName() });
}
// unmarshal analysis results into the original AnalysisProcessData object
// (do not replace CAS type system, as it should not have been changed
// by the service)
resultCargo.unmarshalCas(aCAS, false);
} catch (ServiceException e) {
throw new ResourceServiceException(e);
} catch (java.rmi.RemoteException e) {
throw new ResourceServiceException(e);
} catch (CASException e) {