You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Tanmay Kumar <ta...@isd.nec.co.jp> on 2002/10/10 11:34:45 UTC

Custom Deserializer

Hi all,

Apart from using apache SOAP in my project, we have one more specific
requirement for which Is it possible to use the existing/modifying Apache
source code?
If yes, my requirement is that I want to pass a DOM node to unmarshall()
method of a Deserializer (may be Bean or custom) during runtime and get the
Object as return value.
If the DOM node is like this.


<PesronalInformation type="PesronalInformation">

                             <Name type="String">John</Name>

                             <Age type="int"> 25 </Age>

                             <Address type="Address">

                                           <City type="String">NY</City>

                                           <Street
type="String">OldTraffic</Street>

                             </Address>

</PesronalInformation>

For this, I will call SOAPMappingRegistry#mapTypes() in my client program
for both PesronalInformation and Address as they are complex types.

Also some elements may appear in the DOM node or not.
Ex- in one DOM node during runtime, "Age" field may not be there.

Still in that case I should get object as "new
PesronalInformation("John",0,new Address("NY","OldTraffic"))"
Here 0 is the initialized value for "int" datatype.

If I dont put any value for "Age" in my SOAP client program, still SOAP
request message contains the <Age> element.

My question is,  if this <Age> element would not have been there in XML,
still BeanSerializer could have instantiated the proper object ???
If yes, then I may not need a custom deserializer.

If anything is not clear, please let me know. Any feeadback will be highly
appreciated.

regards,
Tans



Re: Custom Deserializer

Posted by Tanmay Kumar <ta...@isd.nec.co.jp>.
Thanks a lot Scott for your nice explanation.
Due to your explanation only, today we can finalize our project design.

regards,
Tans

----- Original Message ----- 
From: "Scott Nichol" <sn...@scottnichol.com>
To: <so...@xml.apache.org>; <so...@xml.apache.org>
Sent: Thursday, October 10, 2002 10:29 PM
Subject: Re: Custom Deserializer


> > Apart from using apache SOAP in my project, we have one more specific
> > requirement for which Is it possible to use the existing/modifying
> Apache
> > source code?
> 
> Yes, you can modify the source for Apache SOAP and use it if you want.
> 
> > If yes, my requirement is that I want to pass a DOM node to
> unmarshall()
> > method of a Deserializer (may be Bean or custom) during runtime and
> get the
> > Object as return value.
> 
> That it how deserializers always work.
> 
> > If the DOM node is like this.
> >
> >
> > <PesronalInformation type="PesronalInformation">
> >
> >                              <Name type="String">John</Name>
> >
> >                              <Age type="int"> 25 </Age>
> >
> >                              <Address type="Address">
> >
> >                                            <City
> type="String">NY</City>
> >
> >                                            <Street
> > type="String">OldTraffic</Street>
> >
> >                              </Address>
> >
> > </PesronalInformation>
> >
> > For this, I will call SOAPMappingRegistry#mapTypes() in my client
> program
> > for both PesronalInformation and Address as they are complex types.
> 
> That's right.  You can do that without modifying the Apache SOAP code.
> 
> > Also some elements may appear in the DOM node or not.
> > Ex- in one DOM node during runtime, "Age" field may not be there.
> >
> > Still in that case I should get object as "new
> > PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> > Here 0 is the initialized value for "int" datatype.
> >
> > If I dont put any value for "Age" in my SOAP client program, still
> SOAP
> > request message contains the <Age> element.
> >
> > My question is,  if this <Age> element would not have been there in
> XML,
> > still BeanSerializer could have instantiated the proper object ???
> > If yes, then I may not need a custom deserializer.
> 
> The supplied BeanSerializer treats the Java class as a bean: it
> instantiates it with the default (no argument) constructor, then sets
> property values for supplied properties.  It will never call a different
> constructor.  In your case, if there is no Age, then that property value
> will never be set.  Any property that is supplied, however, must be
> writeable, which effectively means it must either be a public field or
> have a public mutator (setter) method.  In the case above, the Name, Age
> and Address properties must be writeable.
> 
> Scott Nichol
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@xml.apache.org>
> For additional commands, e-mail: <ma...@xml.apache.org>
> 
> 


Re: Custom Deserializer

Posted by Tanmay Kumar <ta...@isd.nec.co.jp>.
Thanks a lot Scott for your nice explanation.
Due to your explanation only, today we can finalize our project design.

regards,
Tans

----- Original Message ----- 
From: "Scott Nichol" <sn...@scottnichol.com>
To: <so...@xml.apache.org>; <so...@xml.apache.org>
Sent: Thursday, October 10, 2002 10:29 PM
Subject: Re: Custom Deserializer


> > Apart from using apache SOAP in my project, we have one more specific
> > requirement for which Is it possible to use the existing/modifying
> Apache
> > source code?
> 
> Yes, you can modify the source for Apache SOAP and use it if you want.
> 
> > If yes, my requirement is that I want to pass a DOM node to
> unmarshall()
> > method of a Deserializer (may be Bean or custom) during runtime and
> get the
> > Object as return value.
> 
> That it how deserializers always work.
> 
> > If the DOM node is like this.
> >
> >
> > <PesronalInformation type="PesronalInformation">
> >
> >                              <Name type="String">John</Name>
> >
> >                              <Age type="int"> 25 </Age>
> >
> >                              <Address type="Address">
> >
> >                                            <City
> type="String">NY</City>
> >
> >                                            <Street
> > type="String">OldTraffic</Street>
> >
> >                              </Address>
> >
> > </PesronalInformation>
> >
> > For this, I will call SOAPMappingRegistry#mapTypes() in my client
> program
> > for both PesronalInformation and Address as they are complex types.
> 
> That's right.  You can do that without modifying the Apache SOAP code.
> 
> > Also some elements may appear in the DOM node or not.
> > Ex- in one DOM node during runtime, "Age" field may not be there.
> >
> > Still in that case I should get object as "new
> > PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> > Here 0 is the initialized value for "int" datatype.
> >
> > If I dont put any value for "Age" in my SOAP client program, still
> SOAP
> > request message contains the <Age> element.
> >
> > My question is,  if this <Age> element would not have been there in
> XML,
> > still BeanSerializer could have instantiated the proper object ???
> > If yes, then I may not need a custom deserializer.
> 
> The supplied BeanSerializer treats the Java class as a bean: it
> instantiates it with the default (no argument) constructor, then sets
> property values for supplied properties.  It will never call a different
> constructor.  In your case, if there is no Age, then that property value
> will never be set.  Any property that is supplied, however, must be
> writeable, which effectively means it must either be a public field or
> have a public mutator (setter) method.  In the case above, the Name, Age
> and Address properties must be writeable.
> 
> Scott Nichol
> 
> 
> 
> --
> 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>


Re: Custom Deserializer

Posted by Tanmay Kumar <ta...@isd.nec.co.jp>.
Thanks a lot Scott for your nice explanation.
Due to your explanation only, today we can finalize our project design.

regards,
Tans

----- Original Message ----- 
From: "Scott Nichol" <sn...@scottnichol.com>
To: <so...@xml.apache.org>; <so...@xml.apache.org>
Sent: Thursday, October 10, 2002 10:29 PM
Subject: Re: Custom Deserializer


> > Apart from using apache SOAP in my project, we have one more specific
> > requirement for which Is it possible to use the existing/modifying
> Apache
> > source code?
> 
> Yes, you can modify the source for Apache SOAP and use it if you want.
> 
> > If yes, my requirement is that I want to pass a DOM node to
> unmarshall()
> > method of a Deserializer (may be Bean or custom) during runtime and
> get the
> > Object as return value.
> 
> That it how deserializers always work.
> 
> > If the DOM node is like this.
> >
> >
> > <PesronalInformation type="PesronalInformation">
> >
> >                              <Name type="String">John</Name>
> >
> >                              <Age type="int"> 25 </Age>
> >
> >                              <Address type="Address">
> >
> >                                            <City
> type="String">NY</City>
> >
> >                                            <Street
> > type="String">OldTraffic</Street>
> >
> >                              </Address>
> >
> > </PesronalInformation>
> >
> > For this, I will call SOAPMappingRegistry#mapTypes() in my client
> program
> > for both PesronalInformation and Address as they are complex types.
> 
> That's right.  You can do that without modifying the Apache SOAP code.
> 
> > Also some elements may appear in the DOM node or not.
> > Ex- in one DOM node during runtime, "Age" field may not be there.
> >
> > Still in that case I should get object as "new
> > PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> > Here 0 is the initialized value for "int" datatype.
> >
> > If I dont put any value for "Age" in my SOAP client program, still
> SOAP
> > request message contains the <Age> element.
> >
> > My question is,  if this <Age> element would not have been there in
> XML,
> > still BeanSerializer could have instantiated the proper object ???
> > If yes, then I may not need a custom deserializer.
> 
> The supplied BeanSerializer treats the Java class as a bean: it
> instantiates it with the default (no argument) constructor, then sets
> property values for supplied properties.  It will never call a different
> constructor.  In your case, if there is no Age, then that property value
> will never be set.  Any property that is supplied, however, must be
> writeable, which effectively means it must either be a public field or
> have a public mutator (setter) method.  In the case above, the Name, Age
> and Address properties must be writeable.
> 
> Scott Nichol
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@xml.apache.org>
> For additional commands, e-mail: <ma...@xml.apache.org>
> 
> 


Re: Custom Deserializer

Posted by Tanmay Kumar <ta...@isd.nec.co.jp>.
Thanks a lot Scott for your nice explanation.
Due to your explanation only, today we can finalize our project design.

regards,
Tans

----- Original Message ----- 
From: "Scott Nichol" <sn...@scottnichol.com>
To: <so...@xml.apache.org>; <so...@xml.apache.org>
Sent: Thursday, October 10, 2002 10:29 PM
Subject: Re: Custom Deserializer


> > Apart from using apache SOAP in my project, we have one more specific
> > requirement for which Is it possible to use the existing/modifying
> Apache
> > source code?
> 
> Yes, you can modify the source for Apache SOAP and use it if you want.
> 
> > If yes, my requirement is that I want to pass a DOM node to
> unmarshall()
> > method of a Deserializer (may be Bean or custom) during runtime and
> get the
> > Object as return value.
> 
> That it how deserializers always work.
> 
> > If the DOM node is like this.
> >
> >
> > <PesronalInformation type="PesronalInformation">
> >
> >                              <Name type="String">John</Name>
> >
> >                              <Age type="int"> 25 </Age>
> >
> >                              <Address type="Address">
> >
> >                                            <City
> type="String">NY</City>
> >
> >                                            <Street
> > type="String">OldTraffic</Street>
> >
> >                              </Address>
> >
> > </PesronalInformation>
> >
> > For this, I will call SOAPMappingRegistry#mapTypes() in my client
> program
> > for both PesronalInformation and Address as they are complex types.
> 
> That's right.  You can do that without modifying the Apache SOAP code.
> 
> > Also some elements may appear in the DOM node or not.
> > Ex- in one DOM node during runtime, "Age" field may not be there.
> >
> > Still in that case I should get object as "new
> > PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> > Here 0 is the initialized value for "int" datatype.
> >
> > If I dont put any value for "Age" in my SOAP client program, still
> SOAP
> > request message contains the <Age> element.
> >
> > My question is,  if this <Age> element would not have been there in
> XML,
> > still BeanSerializer could have instantiated the proper object ???
> > If yes, then I may not need a custom deserializer.
> 
> The supplied BeanSerializer treats the Java class as a bean: it
> instantiates it with the default (no argument) constructor, then sets
> property values for supplied properties.  It will never call a different
> constructor.  In your case, if there is no Age, then that property value
> will never be set.  Any property that is supplied, however, must be
> writeable, which effectively means it must either be a public field or
> have a public mutator (setter) method.  In the case above, the Name, Age
> and Address properties must be writeable.
> 
> Scott Nichol
> 
> 
> 
> --
> 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>


Re: Custom Deserializer

Posted by Scott Nichol <sn...@scottnichol.com>.
> Apart from using apache SOAP in my project, we have one more specific
> requirement for which Is it possible to use the existing/modifying
Apache
> source code?

Yes, you can modify the source for Apache SOAP and use it if you want.

> If yes, my requirement is that I want to pass a DOM node to
unmarshall()
> method of a Deserializer (may be Bean or custom) during runtime and
get the
> Object as return value.

That it how deserializers always work.

> If the DOM node is like this.
>
>
> <PesronalInformation type="PesronalInformation">
>
>                              <Name type="String">John</Name>
>
>                              <Age type="int"> 25 </Age>
>
>                              <Address type="Address">
>
>                                            <City
type="String">NY</City>
>
>                                            <Street
> type="String">OldTraffic</Street>
>
>                              </Address>
>
> </PesronalInformation>
>
> For this, I will call SOAPMappingRegistry#mapTypes() in my client
program
> for both PesronalInformation and Address as they are complex types.

That's right.  You can do that without modifying the Apache SOAP code.

> Also some elements may appear in the DOM node or not.
> Ex- in one DOM node during runtime, "Age" field may not be there.
>
> Still in that case I should get object as "new
> PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> Here 0 is the initialized value for "int" datatype.
>
> If I dont put any value for "Age" in my SOAP client program, still
SOAP
> request message contains the <Age> element.
>
> My question is,  if this <Age> element would not have been there in
XML,
> still BeanSerializer could have instantiated the proper object ???
> If yes, then I may not need a custom deserializer.

The supplied BeanSerializer treats the Java class as a bean: it
instantiates it with the default (no argument) constructor, then sets
property values for supplied properties.  It will never call a different
constructor.  In your case, if there is no Age, then that property value
will never be set.  Any property that is supplied, however, must be
writeable, which effectively means it must either be a public field or
have a public mutator (setter) method.  In the case above, the Name, Age
and Address properties must be writeable.

Scott Nichol



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


Re: Custom Deserializer

Posted by Scott Nichol <sn...@scottnichol.com>.
> Apart from using apache SOAP in my project, we have one more specific
> requirement for which Is it possible to use the existing/modifying
Apache
> source code?

Yes, you can modify the source for Apache SOAP and use it if you want.

> If yes, my requirement is that I want to pass a DOM node to
unmarshall()
> method of a Deserializer (may be Bean or custom) during runtime and
get the
> Object as return value.

That it how deserializers always work.

> If the DOM node is like this.
>
>
> <PesronalInformation type="PesronalInformation">
>
>                              <Name type="String">John</Name>
>
>                              <Age type="int"> 25 </Age>
>
>                              <Address type="Address">
>
>                                            <City
type="String">NY</City>
>
>                                            <Street
> type="String">OldTraffic</Street>
>
>                              </Address>
>
> </PesronalInformation>
>
> For this, I will call SOAPMappingRegistry#mapTypes() in my client
program
> for both PesronalInformation and Address as they are complex types.

That's right.  You can do that without modifying the Apache SOAP code.

> Also some elements may appear in the DOM node or not.
> Ex- in one DOM node during runtime, "Age" field may not be there.
>
> Still in that case I should get object as "new
> PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> Here 0 is the initialized value for "int" datatype.
>
> If I dont put any value for "Age" in my SOAP client program, still
SOAP
> request message contains the <Age> element.
>
> My question is,  if this <Age> element would not have been there in
XML,
> still BeanSerializer could have instantiated the proper object ???
> If yes, then I may not need a custom deserializer.

The supplied BeanSerializer treats the Java class as a bean: it
instantiates it with the default (no argument) constructor, then sets
property values for supplied properties.  It will never call a different
constructor.  In your case, if there is no Age, then that property value
will never be set.  Any property that is supplied, however, must be
writeable, which effectively means it must either be a public field or
have a public mutator (setter) method.  In the case above, the Name, Age
and Address properties must be writeable.

Scott Nichol



Re: Custom Deserializer

Posted by Scott Nichol <sn...@scottnichol.com>.
> Apart from using apache SOAP in my project, we have one more specific
> requirement for which Is it possible to use the existing/modifying
Apache
> source code?

Yes, you can modify the source for Apache SOAP and use it if you want.

> If yes, my requirement is that I want to pass a DOM node to
unmarshall()
> method of a Deserializer (may be Bean or custom) during runtime and
get the
> Object as return value.

That it how deserializers always work.

> If the DOM node is like this.
>
>
> <PesronalInformation type="PesronalInformation">
>
>                              <Name type="String">John</Name>
>
>                              <Age type="int"> 25 </Age>
>
>                              <Address type="Address">
>
>                                            <City
type="String">NY</City>
>
>                                            <Street
> type="String">OldTraffic</Street>
>
>                              </Address>
>
> </PesronalInformation>
>
> For this, I will call SOAPMappingRegistry#mapTypes() in my client
program
> for both PesronalInformation and Address as they are complex types.

That's right.  You can do that without modifying the Apache SOAP code.

> Also some elements may appear in the DOM node or not.
> Ex- in one DOM node during runtime, "Age" field may not be there.
>
> Still in that case I should get object as "new
> PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> Here 0 is the initialized value for "int" datatype.
>
> If I dont put any value for "Age" in my SOAP client program, still
SOAP
> request message contains the <Age> element.
>
> My question is,  if this <Age> element would not have been there in
XML,
> still BeanSerializer could have instantiated the proper object ???
> If yes, then I may not need a custom deserializer.

The supplied BeanSerializer treats the Java class as a bean: it
instantiates it with the default (no argument) constructor, then sets
property values for supplied properties.  It will never call a different
constructor.  In your case, if there is no Age, then that property value
will never be set.  Any property that is supplied, however, must be
writeable, which effectively means it must either be a public field or
have a public mutator (setter) method.  In the case above, the Name, Age
and Address properties must be writeable.

Scott Nichol



Re: Custom Deserializer

Posted by Scott Nichol <sn...@scottnichol.com>.
> Apart from using apache SOAP in my project, we have one more specific
> requirement for which Is it possible to use the existing/modifying
Apache
> source code?

Yes, you can modify the source for Apache SOAP and use it if you want.

> If yes, my requirement is that I want to pass a DOM node to
unmarshall()
> method of a Deserializer (may be Bean or custom) during runtime and
get the
> Object as return value.

That it how deserializers always work.

> If the DOM node is like this.
>
>
> <PesronalInformation type="PesronalInformation">
>
>                              <Name type="String">John</Name>
>
>                              <Age type="int"> 25 </Age>
>
>                              <Address type="Address">
>
>                                            <City
type="String">NY</City>
>
>                                            <Street
> type="String">OldTraffic</Street>
>
>                              </Address>
>
> </PesronalInformation>
>
> For this, I will call SOAPMappingRegistry#mapTypes() in my client
program
> for both PesronalInformation and Address as they are complex types.

That's right.  You can do that without modifying the Apache SOAP code.

> Also some elements may appear in the DOM node or not.
> Ex- in one DOM node during runtime, "Age" field may not be there.
>
> Still in that case I should get object as "new
> PesronalInformation("John",0,new Address("NY","OldTraffic"))"
> Here 0 is the initialized value for "int" datatype.
>
> If I dont put any value for "Age" in my SOAP client program, still
SOAP
> request message contains the <Age> element.
>
> My question is,  if this <Age> element would not have been there in
XML,
> still BeanSerializer could have instantiated the proper object ???
> If yes, then I may not need a custom deserializer.

The supplied BeanSerializer treats the Java class as a bean: it
instantiates it with the default (no argument) constructor, then sets
property values for supplied properties.  It will never call a different
constructor.  In your case, if there is no Age, then that property value
will never be set.  Any property that is supplied, however, must be
writeable, which effectively means it must either be a public field or
have a public mutator (setter) method.  In the case above, the Name, Age
and Address properties must be writeable.

Scott Nichol



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