You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Toshiyuki Kimura <ki...@nttdata.co.jp> on 2003/06/26 12:21:33 UTC

RE: help required for attachment using ejb as webservice

Hi Jacek,

 A JAX-RPC implementation is required to support the following MIME
types to bind to various Java types according as JAX-RPC ver 1.0.
In other words, 'application/msword' is not required, basically.

   MIME Type                  |  Java Type
 -----------------------------+-----------------------------------
  image/gif                   | java.awt.Image
  image/jpeg                  | java.awt.Image
  text/plain                  | java.lang.String
  multipart/*                 | javax.mail.internet.MimeMultipart
  text/xml or application/xml | javax.xml.transform.Source

  So if you have any trouble with the DataHandler(obj, mimeType)
and a MIME type not specified above like as 'application/msword',
that meets the specification.

  However, you have a chance to set other MIME types to your response
with a constructor 'DataHandler(DataSource ds)'.
And, please refer to the following site;
 <http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/
  MimetypesFileTypeMap.html>

  If you want to add new entries programmatically, see below;
    <snippet>
      String strMimeType = "application/msword doc";
      javax.activation.MimetypesFileTypeMap map =
                new javax.activation.MimetypesFileTypeMap();
      map.addMimeTypes(strMimeType);
      javax.activation.FileTypeMap.setDefaultFileTypeMap( map );
    </snippet>

P.S.
  It seems that you also have any other mistake on serializer
configuration. Check again.

Best Regards,

   Toshi (Toshiyuki Kimura) <ki...@nttdata.co.jp>
   R&D Headquarters
   NTT DATA Corporation

-----Original Message-----
From: Jacek Gebala [mailto:jag@empolis.pl]
Sent: Wednesday, June 25, 2003 5:34 PM
To: axis-user@ws.apache.org
Cc: kimuratsy@nttdata.co.jp
Subject: RE: help required for attachment using ejb as webservice

Hi Toshi,

Could you please to qualify how I can warp the byte of array to DataHandler?
When I write to:

public DataHandler getAttachment() {
    DataHandler dataHandler = new
DataHandler(ArrayOfBytes,"application/msword");
    return dataHandler;
  }
The error is:
faultString: java.io.IOException: No serializer found for class
javax.activation.CommandInfo in registry
org.apache.axis.encoding.TypeMappingImpl@2370e2

The question is:
Can I use DataHandler constructor (DataHandler(java.lang.Object obj,
java.lang.String mimeType) ) for passing on array of bytes? Type of content
is MS Word document (mimeType: application/msword).
Or should I use specific DataSource class (look at the example below)?
If yes, what the class should I use? I don't see any adequate in package
org.apache.axis.attachments.*;

Anyway, when I try to write a example:

public DataHandler getAttachment() {
    String doc="Hello world.";
    PlainTextDataSource textDS = new PlainTextDataSource("text",doc);
    DataHandler dataHandler = new DataHandler(textDS);
    return dataHandler;
  }

The error is:
faultString: java.io.IOException: No serializer found for class
java.io.ByteArrayOutputStream in registry
org.apache.axis.encoding.TypeMappingImpl@2370e2

What is wrong? I'm confused.
I use WebLogic 7 SP 1, and AXIS 1.1 RC1. I want to use MS SOAP Toolkit 3.0
on client machine.
Do you have any guidelines?

Thanks in advance.

Jacek Gebala
empolis Poland


Re: help required for attachment using ejb as webservice

Posted by Robert Lowe <rm...@rmlowe.com>.
SOAP attachments, MIME types and DataHandlers are explained pretty well in
Chapter 3 of O'Reilly's "Java Web Services in a Nutshell", which is
available for free online:

http://www.oreilly.com/catalog/javawsian/chapter/ch03.pdf


----- Original Message ----- 
From: "Toshiyuki Kimura" <ki...@nttdata.co.jp>
To: <ax...@ws.apache.org>
Sent: Thursday, June 26, 2003 6:21 PM
Subject: RE: help required for attachment using ejb as webservice


> Hi Jacek,
>
>  A JAX-RPC implementation is required to support the following MIME
> types to bind to various Java types according as JAX-RPC ver 1.0.
> In other words, 'application/msword' is not required, basically.
>
>    MIME Type                  |  Java Type
>  -----------------------------+-----------------------------------
>   image/gif                   | java.awt.Image
>   image/jpeg                  | java.awt.Image
>   text/plain                  | java.lang.String
>   multipart/*                 | javax.mail.internet.MimeMultipart
>   text/xml or application/xml | javax.xml.transform.Source
>
>   So if you have any trouble with the DataHandler(obj, mimeType)
> and a MIME type not specified above like as 'application/msword',
> that meets the specification.
>
>   However, you have a chance to set other MIME types to your response
> with a constructor 'DataHandler(DataSource ds)'.
> And, please refer to the following site;
>  <http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/
>   MimetypesFileTypeMap.html>
>
>   If you want to add new entries programmatically, see below;
>     <snippet>
>       String strMimeType = "application/msword doc";
>       javax.activation.MimetypesFileTypeMap map =
>                 new javax.activation.MimetypesFileTypeMap();
>       map.addMimeTypes(strMimeType);
>       javax.activation.FileTypeMap.setDefaultFileTypeMap( map );
>     </snippet>
>
> P.S.
>   It seems that you also have any other mistake on serializer
> configuration. Check again.
>
> Best Regards,
>
>    Toshi (Toshiyuki Kimura) <ki...@nttdata.co.jp>
>    R&D Headquarters
>    NTT DATA Corporation
>
> -----Original Message-----
> From: Jacek Gebala [mailto:jag@empolis.pl]
> Sent: Wednesday, June 25, 2003 5:34 PM
> To: axis-user@ws.apache.org
> Cc: kimuratsy@nttdata.co.jp
> Subject: RE: help required for attachment using ejb as webservice
>
> Hi Toshi,
>
> Could you please to qualify how I can warp the byte of array to
DataHandler?
> When I write to:
>
> public DataHandler getAttachment() {
>     DataHandler dataHandler = new
> DataHandler(ArrayOfBytes,"application/msword");
>     return dataHandler;
>   }
> The error is:
> faultString: java.io.IOException: No serializer found for class
> javax.activation.CommandInfo in registry
> org.apache.axis.encoding.TypeMappingImpl@2370e2
>
> The question is:
> Can I use DataHandler constructor (DataHandler(java.lang.Object obj,
> java.lang.String mimeType) ) for passing on array of bytes? Type of
content
> is MS Word document (mimeType: application/msword).
> Or should I use specific DataSource class (look at the example below)?
> If yes, what the class should I use? I don't see any adequate in package
> org.apache.axis.attachments.*;
>
> Anyway, when I try to write a example:
>
> public DataHandler getAttachment() {
>     String doc="Hello world.";
>     PlainTextDataSource textDS = new PlainTextDataSource("text",doc);
>     DataHandler dataHandler = new DataHandler(textDS);
>     return dataHandler;
>   }
>
> The error is:
> faultString: java.io.IOException: No serializer found for class
> java.io.ByteArrayOutputStream in registry
> org.apache.axis.encoding.TypeMappingImpl@2370e2
>
> What is wrong? I'm confused.
> I use WebLogic 7 SP 1, and AXIS 1.1 RC1. I want to use MS SOAP Toolkit 3.0
> on client machine.
> Do you have any guidelines?
>
> Thanks in advance.
>
> Jacek Gebala
> empolis Poland
>