2 messages in org.apache.xml.soap-userBeanSerializer and interoperability w...| From | Sent On | Attachments |
|---|---|---|
| Corprew Reed | 17 Jan 2001 16:24 | |
| Sanjiva Weerawarana | 19 Jan 2001 08:10 |
| Subject: | BeanSerializer and interoperability with other SOAP implementations.![]() |
|---|---|
| From: | Corprew Reed (corp...@speakeasy.net) |
| Date: | 01/17/2001 04:24:58 PM |
| List: | org.apache.xml.soap-user |
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




