Hi everyone,

I’m working on porting an axis1.1 service over to axis2 and I’m running into a problem with arrays.

 

On the provider side, I need access to the raw soap xml in some cases so that I can pass it off for some custom handling.  The problem is that when the object represents an array, the xml looks significantly different when the array has only one item than when the array has more than one item.

 

Here's a sample section from the wsdl:

 

...

            <s:schema elementFormDefault="qualified" targetNamespace="someservice.com">

                  <s:complexType name="Person">

                        <s:sequence>

                              <s:element name="Name" type="s:string"/>

                              <s:element name="Age" type="s:int"/>

                        </s:sequence>

                  </s:complexType>

                  <s:complexType name="PersonArray">

                        <s:sequence>

                              <s:element name="Person" type="s0:Person" minOccurs="0" maxOccurs="unbounded"/>

                              <s:element name="Description" type="s:string" minOccurs="0" maxOccurs="1"/>

                        </s:sequence>

                  </s:complexType>

                  <s:element name="AddPeople">

                        <s:complexType>

                              <s:sequence>

                                    <s:element name="Category" type="s:string"/>

                                    <s:element name="People" type="s0:PersonArray"/>

                              </s:sequence>

                        </s:complexType>

                  </s:element>

                  <s:element name="AddPeopleResponse">

                        <s:complexType>

                              <s:sequence>

                                    <s:element name="Result" type="s:int"/>

                              </s:sequence>

                        </s:complexType>

                  </s:element>

...

 

 

 

On the consumer side, I execute some code like:

 

            Person p = Person.Factory.newInstance();

            p.setName("Fred");

            p.setAge(32);

           

            Person p2 = Person.Factory.newInstance();

            p2.setName("Barney");

            p2.setAge(34);

 

            PersonArray pa = PersonArray.Factory.newInstance();

            Person[] pArray = new Person[2];

            pArray[0] = p;

            pArray[1] = p2;

 

            pa.setPersonArray(pArray);

 

 

In this case, pa.xmlText() evaluates to:

 

<xml-fragment xmlns:ns="someservice.com">

  <ns:Person>

    <ns:Name>Fred</ns:Name>

    <ns:Age>32</ns:Age>

  </ns:Person>

  <ns:Person>

    <ns:Name>Barney</ns:Name>

    <ns:Age>34</ns:Age>

  </ns:Person>

</xml-fragment>

 

 

Which is as I would expect.  But if I execute:

 

            Person p = Person.Factory.newInstance();

            p.setName("Fred");

            p.setAge(32);

 

            PersonArray pa = PersonArray.Factory.newInstance();

            Person[] pArray = new Person[1];

            pArray[0] = p;

 

            pa.setPersonArray(pArray);

 

 

Then, pa.xmlText() evalutes to:

 

<Person xmlns="someservice.com">

  <Name>Fred</Name>

  <Age>32</Age>

</Person>

 

 

Which isn't really what I would expect.  Instead, I expect something like:

 

<xml-fragment xmlns:ns="someservice.com">

  <ns:Person>

    <ns:Name>Fred</ns:Name>

    <ns:Age>32</ns:Age>

  </ns:Person>

</xml-fragment>

 

That is, I would expect the tag representing the collection/array to be present in its serialization.  In axis1.1, the xml seemed fairly consistent when dealing with arrays.  Has this changed?  Is the above by design or following standards, or is there a bug here?

 

 

Thanks in advance for any suggestions,

 

Dave

 

Reply via email to