Difficulties with collections of objects being XML serialized, and deserializing XML conveying collection of objects

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Difficulties with collections of objects being XML serialized, and deserializing XML conveying collection of objects

Wayne Johnston
I'm having a terrible time and it's likely due to my unfamiliarity with the magic of XML serialization/deserialization.  

I have a bunch of plain old Smalltalk objects generated from a web service WSDL & XSD.

An object of one class (serialized here as "greetingList") intended to hold onto a collection of instances of a second class, serialized here as "greeting".  Made up example.  Paraphrasing the excerpt of my generated XML, I am getting:

<tns1:greetingList>
<item>
<tns1:attribute1>hi</tns1:attribute1>
</item>
<item>
<tns1:attribute1>hello</tns1:attribute1>
</item>
</tns1:greetingList>

As opposed to what I was hoping for (which I get in Java by cobbling together plain old Java objects which I generated from WSDL/XSD):

<tns1:greetingList>
<tns1:greeting>
<tns1:attribute1>hi</tns1:attribute1>
</tns1:greeting>
<tns1:greeting>
<tns1:attribute1>hello</tns1:attribute1>
</tns1:greeting>
</tns1:greetingList>

I should mention that the greetingList attribute is an OrderedCollection of the greeting objects.  The problem seems to be the OrderedCollection (or Array, doesn't matter) doesn't just quietly serialize the elements.

I am having a similar problem taking nice XML produced in Java that conveys a collection of objects and deserializing it in Smalltalk.  I get the expected high level Smalltalk object and some other attributes fine, but the attribute that should be a collection of lower level objects - is instead a SstSoapMappedElement.

I assume I should be able to fix everything with some small piece of cleverness, but am stuck.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Difficulties with collections of objects being XML serialized, and deserializing XML conveying collection of objects

Wayne Johnston
I should have mentioned the XSD excerpt of interest is presumably this (names again changed as above):


<xsd:complexType name="Greeting">
<xsd:sequence>
<xsd:element name="attribute1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="GreetingList">
<xsd:sequence>
<xsd:element name="greeting" minOccurs="0" maxOccurs="unbounded"
type="xs-tns:Greeting"/>
</xsd:sequence>
</xsd:complexType>


<xsd:complexType name="MyRequest">
<xsd:complexContent>
<xsd:extension base="xs-tns:GeneralRequest">
<xsd:sequence>
<xsd:element name="greetingList" nillable="false" type="xs-tns:GreetingList"
/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Difficulties with collections of objects being XML serialized, and deserializing XML conveying collection of objects

Wayne Johnston
In reply to this post by Wayne Johnston
I've determined that the <item> tags, though not what I expected in the XML, cause no problem.  The (Java/Tomcat) web server has no problem turning that XML into arrays of the correct class of object.

I had spent a lot of time trying to find where the <item> tags were coming from.  They aren't in the WSDL or XSD.  But apparently the web server is making them up.  For instance (note the name "item"):

   <complexType name="ArrayOf_xsd_int">
    <sequence>
     <element maxOccurs="unbounded" minOccurs="0" name="item" type="xsd:int"/>
    </sequence>
   </complexType>

So the only problem is in the reverse, with Smalltalk getting back good looking XML, but ending up with a business object with an attribute of a SstSoapMappedElement.  Maybe I'll open a support case asking why that would happen.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.