Hi Kevin,

There's a few things I noticed when looking - especially - at the mapping file.

a) Please supply the namespace definition to the class mapping for the Pair class as well.

That should actually do it.

For the sake of completeness, please change the field mapping for the 'status' member of 'SetStatusRequest' to

<field name="status" type="com.xx.xxx.tecommon.Pair" collection="array">
  <bind-xml name="status" node="element" />
</field>


Regards
Werner

On 16.12.2010 13:13, Kevin Kilroy wrote:
Hi,

I'm having great difficulty unmarshalling some XML into an array
object in Java. Here is my mapping file:

<class
                name="com.xx.service.web.SetStatusRequest">
                <map-to xml="SetStatusRequest" 
ns-uri="http://xx.com/xxx/serversession"; />
                <field name="errorCode" type="int">
                        <bind-xml name="errorCode" node="element" type="int" />
                </field>
                <field name="status" type="com.xx.xxx.tecommon.Pair" 
collection="array">
                        <bind-xml name="status" node="element" 
type="com.xx.xxx.tecommon.Pair"   />
                </field>
        </class>

<class name="com.xx.xxx.tecommon.Pair">
                <map-to xml="pair" />
                <field name="name" type="string">
                        <bind-xml name="name" node="element" type="string" />
                </field>
                <field name="value" type="string">
                        <bind-xml name="value" node="element" type="string"  />
                </field>
        </class>

And the Java Classes

public class SetStatusRequest   {

     private int errorCode;

     private com.xx.xxx.tecommon.Pair[] status;

     public com.te.amptrac.tecommon.Pair[] getStatus() {
         return status;
     }
    public void setStatus(com.te.amptrac.tecommon.Pair[] status) {
         this.status = status;
     }
}

public class Pair  {
     private String name;

     private String value;

     public java.lang.String getName() {
         return name;
     }

     public void setName(java.lang.String name) {
         this.name = name;
     }

     public java.lang.String getValue() {
         return value;
     }

     public void setValue(java.lang.String value) {
         this.value = value;
     }

}

And the XML That I am trying to unmarshall looks like this:
<SetStatusRequest xmlns="http://xx.com/xxx/serversession";>
<errorCode>0</errorCode>
<status>
<name>status</name>
<value>1</value>
</status>
<status>
<name>status</name>
<value>1</value>
</status>
</SetStatusRequest>

The errorCode field is loaded into the object correctly, however the
status array field is always null.

I'm using Castor 1.2.0


Any help would be greatly appreciated.

Thanks in advance,

Kevin.

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

     http://xircles.codehaus.org/manage_email




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

   http://xircles.codehaus.org/manage_email


Reply via email to