Andreas,

Thanks for your reply. Actually I am trying to invoke a service which
returns a DataHandler through MTOM. I have following code in the service
class:

FileItem file = (FileItem) value;
ByteArrayDataSource bads = new ByteArrayDataSource(file.getInputStream(),
"application/msword");
bads.setName("abc.doc");
return new DataHandler(bads);


So far so good. The newly created DataHandler preserve the name. I have
following code in the client end from where I am invoking the service:

     ServiceClient sender = new ServiceClient();
      sender.setOptions(options);
      OMFactory fac = OMAbstractFactory.getOMFactory();
      OMNamespace ns = fac.createOMNamespace("http://www.abc.com/webservice";,
"ns");
      OMElement payload = createPayload(ns, argNameList, args);
      OMElement retVal = sender.sendReceive(payload);
      if (retVal != null) {
          OMElement ele = retVal.getFirstElement();
          OMText binaryNode = (OMText) ele.getFirstOMChild();
          binaryNode.setOptimize(true);
          return (DataHandler) binaryNode.getDataHandler();
      }

I am trying to return a .doc file. When I receive the datahandler in the
client end DataHandler#getName() returns "MyByteArrayDataSource" and the
content type becomes "application/octet-stream" meaning binary.

Hope I made you understand the problem. May be the code
"binaryNode.setOptimize(true);" made the content-type binary. Then how to
get a .doc or other file type?

Chinmoy





On Wed, Mar 25, 2009 at 1:29 PM, Chinmoy Chakraborty <[email protected]>wrote:

> Hi All,
>
> I noticed DataHandler.getName() always returns 'MyByteArrayDataSource' if
> the data source is ByteArrayDataSource from which the DataHandler has been
> created. Please look at the code below:
>
> FileItem file = (FileItem) value;
> ByteArrayDataSource bads = new ByteArrayDataSource(file.getInputStream(),
> "application/msword");
> bads.setName("abc.doc");
> DataHandler dh = new DataHandler(bads);
>
> Now if I do, dh.getName(), it always returns 'MyByteArrayDataSource". I
> guess this is a bug. Whats your opinion?
>
>
> Chinmoy
>

Reply via email to