I am trying to implement Castor to put XML requests into a Java object.
On a very simple input request, I was able to make it work, but I have
an issue now with moderately more complex ones.

I used the source generator tool to create classes from a schema file
for the request. The XML request itself looks like this.

<GetAccountBalancesRequest>
  <MSSTInd>false</MSSTInd>
    <Accounts>
      <Account>
        <AcctNo>X10152382</AcctNo>
        <CESGInd>false</CESGInd>
      </Account>
      <Account>
        <AcctNo>X10625310</AcctNo>
        <CESGInd>false</CESGInd>
      </Account>
    </Accounts>
</GetAccountBalancesRequest>

The Schema for that looks like this.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<xsd:element name="CESGInd" type="xsd:string"/>
<xsd:element name="GetAccountBalancesRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="MSSTInd"/>
<xsd:element ref="Accounts"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AcctNo" type="xsd:string"/>
<xsd:element name="MSSTInd" type="xsd:string"/>
<xsd:element name="Account">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="AcctNo"/>
<xsd:element ref="CESGInd"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Accounts">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" ref="Account"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

I ran the SourceGenerator to create the classes, and ended up with an
Account, Accounts, and GetAccountBalancesRequest java files.

I put those in place in my code, and run it something like this.

GetAccountBalancesRequest inputRequest = new
GetAccountBalancesRequest();
inputRequest= GetAccountBalancesRequest.unmarshal(new
StringReader(xmltmp));

When I do that, and look at the contents of inputRequest, the MSSTInd
field is populated ok, but the accounts are null. It seems it's doing on
with the simple elements, but not properly dealing with the complex
elements.

Anyone do anything similar, and run into these issues? Something else I
should be doing here that I'm missing? This is my first try at using
Castor like this.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to