Uploaded image for project: 'Axis'
  1. Axis
  2. AXIS-1569

Problems with Deserialzing Arrays by the Axis Servlet and the Axis Client for a Doc/Literal service

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • beta-3
    • None
    • None
    • axis-1_2beta3, Java 1.4.2, Tomcat 5.0.27, WindowsXP(Professional)

    Description

      Some Background
      ===============
      STEP1: Created a very simple class TestService, which contains a method hello(), that merely returns the input
      public class TestService {
      public Bean hello(Bean input)

      {return input; }

      }

      STEP 2: The input is a Bean instance, that has properties of types String, Integer, Date and String[]
      public class Bean {
      private String stringField;
      private Integer integerField;
      private java.util.Date dateField;
      private String[] stringArray;
      ...
      }

      STEP 3: TestService.wsdl was then created manually, to expose the above method as a webservice. The following fragment shows the description of the Bean in the WSDL.
      ...
      <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.example.com/types">
      <complexType name="Bean">
      <sequence>
      <element name="stringField" nillable="true" type="xsd:string"/>
      <element name="integerField" nillable="true" type="xsd:int"/>
      <element name="dateField" nillable="true" type="xsd:dateTime"/>
      <element name="stringArray" nillable="true" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
      </sequence>
      </complexType>
      </schema>
      ...

      STEP 4: Used the axis-wsdl2java task to generate deployment descriptors and test stubs from the WSDL. Used the following code in the test class to invoke the webservice
      ...
      Bean input = new Bean();
      input.setStringField("TEST STRING");
      input.setIntegerField(new Integer(1001));
      input.setDateField(new java.util.GregorianCalendar());
      input.setStringArray(new String[]

      {"aa", "bb", "cc"}

      );
      Bean output = binding.hello(input);
      ...

      Problems
      ========
      1- Only the last object in the StringArray property is made available to the TestService by the Axis Servlet. Eg. For the above test code, only the String "cc" is available to the hello() method

      2- The client throws the following error, when deserializing the output from the webservice
      org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
      at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:149)
      at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1025)
      at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:159)
      at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:845)
      at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:198)
      at org.apache.axis.message.RPCElement.getParams(RPCElement.java:323)
      at org.apache.axis.client.Call.invoke(Call.java:2418)
      at org.apache.axis.client.Call.invoke(Call.java:2317)
      at org.apache.axis.client.Call.invoke(Call.java:1774)
      at com.example.TestServiceSoapBindingStub.hello(TestServiceSoapBindingStub.java:144)
      at com.example.TestServiceServiceTestCase.test1TestServiceHello(TestServiceServiceTestCase.java:42)

      3- Invoked the webservice from the .NET WebService Studio. Again, only the last element in the StringArray property is made available to the TestService by the Axis Servlet
      Input
      ====
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <helloInput xmlns="http://www.example.com/wsdl">
      <stringField>TEST STRING</stringField>
      <integerField>1001</integerField>
      <dateField>2004-09-22T00:00:00.0000000-07:00</dateField>
      <stringArray>aa</stringArray>
      <stringArray>bb</stringArray>
      <stringArray>cc</stringArray>
      </helloInput>
      </soap:Body>
      </soap:Envelope>

      Output
      =====
      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <helloReturn xmlns="http://www.example.com/wsdl">
      <dateField>2004-09-22T07:00:00.000Z</dateField>
      <integerField>1001</integerField>
      <stringArray>
      <item xmlns="">cc</item>
      </stringArray>
      <stringField>TEST STRING</stringField>
      </helloReturn>
      </soapenv:Body>
      </soapenv:Envelope>

      Attachments

        1. TestServiceServiceTestCase.java
          2 kB
          Kachra Patti
        2. TestService-deploy.wsdd
          2 kB
          Kachra Patti
        3. TestService.wsdl
          3 kB
          Kachra Patti
        4. TestService.java
          0.3 kB
          Kachra Patti
        5. Bean.java
          3 kB
          Kachra Patti

        Activity

          People

            Unassigned Unassigned
            kachra_patti Kachra Patti
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: