axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject file size content length java patch to
Date Fri, 30 Jan 2009 10:36:42 GMT


We are decoding streams of XML using Java to extract the documents and
are then using Axis to send the extracted documents onwards to a 3rd
party DotNet system. We found that Axis was trying to look for the file
data on disk to determine the content length of the document data. This
was failing as the data is not on disk. We did not want to flush the
data to a temporary disk file. We have patched the Axis code to resolve
this issue. The attached patch to checks whether the
DataHandler implements a new interface ContentLength. If it does it uses
the method on that interface to determine the size of the content else
it uses the existing logic. I have also attached our client class
VirtualFileDataSource that extends FileDataSource and implements
ContentLength that we pass to Axis. 

Here is a snippet of code that shows how we send data via axis using
patched code: 

public String putDocument(final String uniqueName, final Integer
			final String contentType, final InputStream dataStream, int length)
			throws RemoteException {

		Service service = new Service();
		Call call = null;
		try {
			call = (Call) service.createCall();
		} catch (ServiceException e) {
			logger.error("Could not create axis.client.Service.", e);

				.setOperationName(new QName(

		call.addParameter("DocumentId", Constants.XSD_STRING,
		call.addParameter("DocumentReference", Constants.XSD_STRING,
		call.addParameter("DocumentVersion", Constants.XSD_STRING,


		// Create the virtual file data source for the in-memory InputStream 
		DataHandler dhSource = new DataHandler(new VirtualFileDataSource(
				uniqueName, contentType, dataStream, length));

		QName qnameAttachment = new QName("urn:EchoAttachmentsService",

				dhSource.getClass(), // Add serializer for attachment.
				qnameAttachment, JAFDataHandlerSerializerFactory.class,

		call.addParameter("source", qnameAttachment, ParameterMode.IN);

		String ret = (String) call.invoke(new Object[] { null, uniqueName,
				version, dhSource });



View raw message