You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Vamsi Krishna <va...@sun.com> on 2003/01/10 04:06:35 UTC

Can I override the MimePartSerializer?? - Need Help Soon

hi All,

My service has a method -  saveJPEG(String name, java.awt.Image img) 
 taking a name and a jpeg image and saving that jpeg with that name in a 
specified directory.
I am using SOAP RPC. Since there is no Serializer/Deserializer for Image 
type, i created my ImageSerializerDeserializer. The DD specifies this 
info. The client also does the mapTypes with this info. What I do in 
this class is - in the marshall method, i take the Image source, convert 
it into a DataHandler object and call the MimePartSerializer with the 
DataHandler object (i simply pass all the other parameters onto 
MimePartSerializer - only the src is changed to dhsrc).
In the unmarshall method - i first call the 
MimePartSerializer.unmarshall method and get the Bean. Since i know it 
is Image, i convert the DataHandler value in this bean to an Image 
object and create and return that Image bean.

So the client works fine now - my ImageSerializer's marshall method gets 
called and the call goes through to the Server. The problem is in the 
Deserialization. My ImageSerializer class's  unmarshall method is never 
called at the server end. Always the MimePartSerializer.unmarshall is 
called and I get a fault saying there is no such method that accepts a 
DataHandler - saveJPEG(java.lang.String,javax.activation.DataHandler).

What is the problem here? Is there a way to override the deserializer 
for javax.activation.DataHandler? Is my approach correct?
(I know i can have an overloaded method with this signature taking the 
data handler and in this method convert the dh to image and call my 
original method. But this is not what i am looking for.)


I appreciate any help in this.

thanks a lot in advance,
Vamsi.


The DD entry is -
<isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xmlns:x="urn:xml-soap-j2eeca-soapattach-serverSaveJPEG"
            qname="x:Image"
            javaType="java.awt.Image"
            java2XMLClassName="soapattach.soap.serializers.ImageSerializer"
            
xml2JavaClassName="soapattach.soap.serializers.ImageSerializer" />


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>


Re: Can I override the MimePartSerializer?? - Need Help Soon

Posted by Scott Nichol <sn...@scottnichol.com>.
Unfortunately, DataHandlers are serialized as attachments, and
attachments are always deserialized as DataHandlers.  Therefore, your
deserializer cannot work with the existing Apache SOAP code.

A fairly simple alternative would be to have an Image [de-]serializer
that delegates to the Base64Serializer.  The jpeg gets managed as a byte
array, but you specify the javaType as Image so that the xsi:type
attribute reflects its origins and the byte array can be deserialized to
an Image.  This is not as efficient as the DataHandler (Base64 takes 33%
more space than straight bytes), but it will function with minimal work.

Scott Nichol

----- Original Message -----
From: "Vamsi Krishna" <va...@sun.com>
To: <so...@xml.apache.org>
Sent: Thursday, January 09, 2003 10:06 PM
Subject: Can I override the MimePartSerializer?? - Need Help Soon


> hi All,
>
> My service has a method -  saveJPEG(String name, java.awt.Image img)
>  taking a name and a jpeg image and saving that jpeg with that name in
a
> specified directory.
> I am using SOAP RPC. Since there is no Serializer/Deserializer for
Image
> type, i created my ImageSerializerDeserializer. The DD specifies this
> info. The client also does the mapTypes with this info. What I do in
> this class is - in the marshall method, i take the Image source,
convert
> it into a DataHandler object and call the MimePartSerializer with the
> DataHandler object (i simply pass all the other parameters onto
> MimePartSerializer - only the src is changed to dhsrc).
> In the unmarshall method - i first call the
> MimePartSerializer.unmarshall method and get the Bean. Since i know it
> is Image, i convert the DataHandler value in this bean to an Image
> object and create and return that Image bean.
>
> So the client works fine now - my ImageSerializer's marshall method
gets
> called and the call goes through to the Server. The problem is in the
> Deserialization. My ImageSerializer class's  unmarshall method is
never
> called at the server end. Always the MimePartSerializer.unmarshall is
> called and I get a fault saying there is no such method that accepts a
> DataHandler - saveJPEG(java.lang.String,javax.activation.DataHandler).
>
> What is the problem here? Is there a way to override the deserializer
> for javax.activation.DataHandler? Is my approach correct?
> (I know i can have an overloaded method with this signature taking the
> data handler and in this method convert the dh to image and call my
> original method. But this is not what i am looking for.)
>
>
> I appreciate any help in this.
>
> thanks a lot in advance,
> Vamsi.
>
>
> The DD entry is -
> <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>             xmlns:x="urn:xml-soap-j2eeca-soapattach-serverSaveJPEG"
>             qname="x:Image"
>             javaType="java.awt.Image"
>
java2XMLClassName="soapattach.soap.serializers.ImageSerializer"
>
> xml2JavaClassName="soapattach.soap.serializers.ImageSerializer" />
>
>
> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>
>
>


Re: Can I override the MimePartSerializer?? - Need Help Soon

Posted by Scott Nichol <sn...@scottnichol.com>.
Unfortunately, DataHandlers are serialized as attachments, and
attachments are always deserialized as DataHandlers.  Therefore, your
deserializer cannot work with the existing Apache SOAP code.

A fairly simple alternative would be to have an Image [de-]serializer
that delegates to the Base64Serializer.  The jpeg gets managed as a byte
array, but you specify the javaType as Image so that the xsi:type
attribute reflects its origins and the byte array can be deserialized to
an Image.  This is not as efficient as the DataHandler (Base64 takes 33%
more space than straight bytes), but it will function with minimal work.

Scott Nichol

----- Original Message -----
From: "Vamsi Krishna" <va...@sun.com>
To: <so...@xml.apache.org>
Sent: Thursday, January 09, 2003 10:06 PM
Subject: Can I override the MimePartSerializer?? - Need Help Soon


> hi All,
>
> My service has a method -  saveJPEG(String name, java.awt.Image img)
>  taking a name and a jpeg image and saving that jpeg with that name in
a
> specified directory.
> I am using SOAP RPC. Since there is no Serializer/Deserializer for
Image
> type, i created my ImageSerializerDeserializer. The DD specifies this
> info. The client also does the mapTypes with this info. What I do in
> this class is - in the marshall method, i take the Image source,
convert
> it into a DataHandler object and call the MimePartSerializer with the
> DataHandler object (i simply pass all the other parameters onto
> MimePartSerializer - only the src is changed to dhsrc).
> In the unmarshall method - i first call the
> MimePartSerializer.unmarshall method and get the Bean. Since i know it
> is Image, i convert the DataHandler value in this bean to an Image
> object and create and return that Image bean.
>
> So the client works fine now - my ImageSerializer's marshall method
gets
> called and the call goes through to the Server. The problem is in the
> Deserialization. My ImageSerializer class's  unmarshall method is
never
> called at the server end. Always the MimePartSerializer.unmarshall is
> called and I get a fault saying there is no such method that accepts a
> DataHandler - saveJPEG(java.lang.String,javax.activation.DataHandler).
>
> What is the problem here? Is there a way to override the deserializer
> for javax.activation.DataHandler? Is my approach correct?
> (I know i can have an overloaded method with this signature taking the
> data handler and in this method convert the dh to image and call my
> original method. But this is not what i am looking for.)
>
>
> I appreciate any help in this.
>
> thanks a lot in advance,
> Vamsi.
>
>
> The DD entry is -
> <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>             xmlns:x="urn:xml-soap-j2eeca-soapattach-serverSaveJPEG"
>             qname="x:Image"
>             javaType="java.awt.Image"
>
java2XMLClassName="soapattach.soap.serializers.ImageSerializer"
>
> xml2JavaClassName="soapattach.soap.serializers.ImageSerializer" />
>
>
> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>