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 Corprew Reed <co...@speakeasy.net> on 2001/01/18 01:24:58 UTC

BeanSerializer and interoperability with other SOAP implementations.

Hi.

I've been using Apache SOAP for a while, and I'd like to propose a 
change to the BeanSerializer to make it more interoperable with 
other SOAP implementations.  Specifically, I propose changing the
case comparison within the getWriteMethod method of the BeanSerializer 
to be case-insensitive rather than case-sensitive as it is today.

I feel this will have the following benefits:
        (1) This will enable the BeanSerializer to unmarshall serialized
            objects that have element names with the first letter capitalized.
            This is good for interoperability with other soap implementations.
        (2) It will apply the maxim 'be conservative in what you send,
            be liberal in what you accept.'

A longer explanation and the proposed code change follows.

I have a bean defined more or less as follows:

public class SerProp
{
	String name;
	String label;
	[..others..]
}

Additionally, it has the get and set methods that you'd expect to find 
in a Bean.  Serializing this class works fine.  However, the SOAP
server receiving the message is not Apache SOAP, and replies with
the following serialization of the same objects...

[...]
	<return  xmlns:ns3="http://xml.apache.org/xml-soap" xsi:type="ns3:Vector" >
  <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
	<Name xsi:type="xsd:string">OIID</Name>
	<Label xsi:type="xsd:string">OIID</Label>
	[...]
  </item>
  <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
	<Name xsi:type="xsd:string">Id</Name>
	<Label xsi:type="xsd:string">Id</Label>
	[...]
  </item>
	</return>
[...]

(The BeanSerializer class referred to in the following is in the package 
org.apache.soap.encoding.soapenc.)

The important thing to note in this serialization is that the element
names are capitalized.  Everything on the client side is registered 
properly, and the BeanSerializer is invoked to unmarshall the object.  

When BeanSerializer.unmarshall(...) invokes BeanSerializer.getWriteMethod(...),
it invokes it with the name of the parameter as contained in the
xml element.  For example, 'Name'.  

However, in BeanSerializer.getPropertyDescriptions(...), the
BeanInfo will return lower case names for the properties of the bean.  
For example, 'name'.  

Because the cases of these two strings do not match,  the following
code from getWriteMethod will not find a matching PropertyDescriptor,
and an IllegalArgumentException will be thrown.

    for (int i = 0; i < pds.length; i++)
    {
      if (propertyName.equals(pds[i].getName()))
      {
        return pds[i].getWriteMethod();
      }
    }

I suggest that this fragment be changed to do case-insensitive comparisons,
as follows:

    for (int i = 0; i < pds.length; i++)
    {
      if (0 == propertyName.compareToIgnoreCase(pds[i].getName()))
      {
        return pds[i].getWriteMethod();
      }
    }

This will have the benefits listed above.  I can also send this as a diff
if desired.

Thanks for your time,

--Corprew

Re: BeanSerializer and interoperability with other SOAP implementations.

Posted by Sanjiva Weerawarana <sa...@watson.ibm.com>.
This would be inconsistent with respect to the JavaBeans spec,
but I'm inclined to doing it on the basis of improving usability.
Do other committers have an opinion on this?

Sanjiva.

----- Original Message -----
From: "Corprew Reed" <co...@speakeasy.net>
To: <so...@xml.apache.org>
Sent: Wednesday, January 17, 2001 7:24 PM
Subject: BeanSerializer and interoperability with other SOAP implementations.


> Hi.
>
> I've been using Apache SOAP for a while, and I'd like to propose a
> change to the BeanSerializer to make it more interoperable with
> other SOAP implementations.  Specifically, I propose changing the
> case comparison within the getWriteMethod method of the BeanSerializer
> to be case-insensitive rather than case-sensitive as it is today.
>
> I feel this will have the following benefits:
>         (1) This will enable the BeanSerializer to unmarshall serialized
>             objects that have element names with the first letter
capitalized.
>             This is good for interoperability with other soap
implementations.
>         (2) It will apply the maxim 'be conservative in what you send,
>             be liberal in what you accept.'
>
> A longer explanation and the proposed code change follows.
>
> I have a bean defined more or less as follows:
>
> public class SerProp
> {
> String name;
> String label;
> [..others..]
> }
>
> Additionally, it has the get and set methods that you'd expect to find
> in a Bean.  Serializing this class works fine.  However, the SOAP
> server receiving the message is not Apache SOAP, and replies with
> the following serialization of the same objects...
>
> [...]
> <return  xmlns:ns3="http://xml.apache.org/xml-soap" xsi:type="ns3:Vector" >
>   <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
> <Name xsi:type="xsd:string">OIID</Name>
> <Label xsi:type="xsd:string">OIID</Label>
> [...]
>   </item>
>   <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
> <Name xsi:type="xsd:string">Id</Name>
> <Label xsi:type="xsd:string">Id</Label>
> [...]
>   </item>
> </return>
> [...]
>
> (The BeanSerializer class referred to in the following is in the package
> org.apache.soap.encoding.soapenc.)
>
> The important thing to note in this serialization is that the element
> names are capitalized.  Everything on the client side is registered
> properly, and the BeanSerializer is invoked to unmarshall the object.
>
> When BeanSerializer.unmarshall(...) invokes
BeanSerializer.getWriteMethod(...),
> it invokes it with the name of the parameter as contained in the
> xml element.  For example, 'Name'.
>
> However, in BeanSerializer.getPropertyDescriptions(...), the
> BeanInfo will return lower case names for the properties of the bean.
> For example, 'name'.
>
> Because the cases of these two strings do not match,  the following
> code from getWriteMethod will not find a matching PropertyDescriptor,
> and an IllegalArgumentException will be thrown.
>
>     for (int i = 0; i < pds.length; i++)
>     {
>       if (propertyName.equals(pds[i].getName()))
>       {
>         return pds[i].getWriteMethod();
>       }
>     }
>
> I suggest that this fragment be changed to do case-insensitive comparisons,
> as follows:
>
>     for (int i = 0; i < pds.length; i++)
>     {
>       if (0 == propertyName.compareToIgnoreCase(pds[i].getName()))
>       {
>         return pds[i].getWriteMethod();
>       }
>     }
>
> This will have the benefits listed above.  I can also send this as a diff
> if desired.
>
> Thanks for your time,
>
> --Corprew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
> For additional commands, email: soap-user-help@xml.apache.org
>


Re: BeanSerializer and interoperability with other SOAP implementations.

Posted by Sanjiva Weerawarana <sa...@watson.ibm.com>.
This would be inconsistent with respect to the JavaBeans spec,
but I'm inclined to doing it on the basis of improving usability.
Do other committers have an opinion on this?

Sanjiva.

----- Original Message -----
From: "Corprew Reed" <co...@speakeasy.net>
To: <so...@xml.apache.org>
Sent: Wednesday, January 17, 2001 7:24 PM
Subject: BeanSerializer and interoperability with other SOAP implementations.


> Hi.
>
> I've been using Apache SOAP for a while, and I'd like to propose a
> change to the BeanSerializer to make it more interoperable with
> other SOAP implementations.  Specifically, I propose changing the
> case comparison within the getWriteMethod method of the BeanSerializer
> to be case-insensitive rather than case-sensitive as it is today.
>
> I feel this will have the following benefits:
>         (1) This will enable the BeanSerializer to unmarshall serialized
>             objects that have element names with the first letter
capitalized.
>             This is good for interoperability with other soap
implementations.
>         (2) It will apply the maxim 'be conservative in what you send,
>             be liberal in what you accept.'
>
> A longer explanation and the proposed code change follows.
>
> I have a bean defined more or less as follows:
>
> public class SerProp
> {
> String name;
> String label;
> [..others..]
> }
>
> Additionally, it has the get and set methods that you'd expect to find
> in a Bean.  Serializing this class works fine.  However, the SOAP
> server receiving the message is not Apache SOAP, and replies with
> the following serialization of the same objects...
>
> [...]
> <return  xmlns:ns3="http://xml.apache.org/xml-soap" xsi:type="ns3:Vector" >
>   <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
> <Name xsi:type="xsd:string">OIID</Name>
> <Label xsi:type="xsd:string">OIID</Label>
> [...]
>   </item>
>   <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
> <Name xsi:type="xsd:string">Id</Name>
> <Label xsi:type="xsd:string">Id</Label>
> [...]
>   </item>
> </return>
> [...]
>
> (The BeanSerializer class referred to in the following is in the package
> org.apache.soap.encoding.soapenc.)
>
> The important thing to note in this serialization is that the element
> names are capitalized.  Everything on the client side is registered
> properly, and the BeanSerializer is invoked to unmarshall the object.
>
> When BeanSerializer.unmarshall(...) invokes
BeanSerializer.getWriteMethod(...),
> it invokes it with the name of the parameter as contained in the
> xml element.  For example, 'Name'.
>
> However, in BeanSerializer.getPropertyDescriptions(...), the
> BeanInfo will return lower case names for the properties of the bean.
> For example, 'name'.
>
> Because the cases of these two strings do not match,  the following
> code from getWriteMethod will not find a matching PropertyDescriptor,
> and an IllegalArgumentException will be thrown.
>
>     for (int i = 0; i < pds.length; i++)
>     {
>       if (propertyName.equals(pds[i].getName()))
>       {
>         return pds[i].getWriteMethod();
>       }
>     }
>
> I suggest that this fragment be changed to do case-insensitive comparisons,
> as follows:
>
>     for (int i = 0; i < pds.length; i++)
>     {
>       if (0 == propertyName.compareToIgnoreCase(pds[i].getName()))
>       {
>         return pds[i].getWriteMethod();
>       }
>     }
>
> This will have the benefits listed above.  I can also send this as a diff
> if desired.
>
> Thanks for your time,
>
> --Corprew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
> For additional commands, email: soap-user-help@xml.apache.org
>


Re: BeanSerializer and interoperability with other SOAP implementations.

Posted by Sanjiva Weerawarana <sa...@watson.ibm.com>.
This would be inconsistent with respect to the JavaBeans spec,
but I'm inclined to doing it on the basis of improving usability.
Do other committers have an opinion on this?

Sanjiva.

----- Original Message -----
From: "Corprew Reed" <co...@speakeasy.net>
To: <so...@xml.apache.org>
Sent: Wednesday, January 17, 2001 7:24 PM
Subject: BeanSerializer and interoperability with other SOAP implementations.


> Hi.
>
> I've been using Apache SOAP for a while, and I'd like to propose a
> change to the BeanSerializer to make it more interoperable with
> other SOAP implementations.  Specifically, I propose changing the
> case comparison within the getWriteMethod method of the BeanSerializer
> to be case-insensitive rather than case-sensitive as it is today.
>
> I feel this will have the following benefits:
>         (1) This will enable the BeanSerializer to unmarshall serialized
>             objects that have element names with the first letter
capitalized.
>             This is good for interoperability with other soap
implementations.
>         (2) It will apply the maxim 'be conservative in what you send,
>             be liberal in what you accept.'
>
> A longer explanation and the proposed code change follows.
>
> I have a bean defined more or less as follows:
>
> public class SerProp
> {
> String name;
> String label;
> [..others..]
> }
>
> Additionally, it has the get and set methods that you'd expect to find
> in a Bean.  Serializing this class works fine.  However, the SOAP
> server receiving the message is not Apache SOAP, and replies with
> the following serialization of the same objects...
>
> [...]
> <return  xmlns:ns3="http://xml.apache.org/xml-soap" xsi:type="ns3:Vector" >
>   <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
> <Name xsi:type="xsd:string">OIID</Name>
> <Label xsi:type="xsd:string">OIID</Label>
> [...]
>   </item>
>   <item xmlns:ns0="urn:javaapi0" xsi:type="ns0:property">
> <Name xsi:type="xsd:string">Id</Name>
> <Label xsi:type="xsd:string">Id</Label>
> [...]
>   </item>
> </return>
> [...]
>
> (The BeanSerializer class referred to in the following is in the package
> org.apache.soap.encoding.soapenc.)
>
> The important thing to note in this serialization is that the element
> names are capitalized.  Everything on the client side is registered
> properly, and the BeanSerializer is invoked to unmarshall the object.
>
> When BeanSerializer.unmarshall(...) invokes
BeanSerializer.getWriteMethod(...),
> it invokes it with the name of the parameter as contained in the
> xml element.  For example, 'Name'.
>
> However, in BeanSerializer.getPropertyDescriptions(...), the
> BeanInfo will return lower case names for the properties of the bean.
> For example, 'name'.
>
> Because the cases of these two strings do not match,  the following
> code from getWriteMethod will not find a matching PropertyDescriptor,
> and an IllegalArgumentException will be thrown.
>
>     for (int i = 0; i < pds.length; i++)
>     {
>       if (propertyName.equals(pds[i].getName()))
>       {
>         return pds[i].getWriteMethod();
>       }
>     }
>
> I suggest that this fragment be changed to do case-insensitive comparisons,
> as follows:
>
>     for (int i = 0; i < pds.length; i++)
>     {
>       if (0 == propertyName.compareToIgnoreCase(pds[i].getName()))
>       {
>         return pds[i].getWriteMethod();
>       }
>     }
>
> This will have the benefits listed above.  I can also send this as a diff
> if desired.
>
> Thanks for your time,
>
> --Corprew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
> For additional commands, email: soap-user-help@xml.apache.org
>