0 Replies Latest reply on Jun 24, 2004 10:37 AM by Matthias Zint

    Problem with String Array // How to access Array content in

    Matthias Zint Newbie

      Hi everybody,

      I have 2 questions regarding WebServices DataTypes:

      1. Problem with String Arrays

      I created a function in J2EE exposed as a web-service that returns a string array to the caller:

      /**
       * @jboss-net.web-method
       * @jboss-net.wsdd-operation
       * @ejb.interface-method view-type = "remote"
       */
       public String[] testStringArray(){
       String s[] = {"test","string"};
       return s;
       }


      When I call this function in a C# Client - I get an System.InvalidOperationException that states that there is an error in the XML-Document.

      Part of the WSDL looks like this:

      ...
      - <complexType name="ArrayOf_xsd_string">
      - <complexContent>
      - <restriction base="soapenc:Array">
       <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]" />
       </restriction>
       </complexContent>
       </complexType>
      ...
       <wsdl:message name="testStringArrayRequest" />
      ...
      - <wsdl:message name="testStringArrayResponse">
       <wsdl:part name="testStringArrayReturn" type="impl:ArrayOf_xsd_string" />
       </wsdl:message>


      If I transfer an int-array everything works fine. Does this have something to do with the way XDoclet generates the WSDL-file ?? Or is this a fault of the WSDL generator from Microsoft.


      2. Accessing Array content in C#

      If I transfer an int-array everyting works fine:

      /**
       * @jboss-net.web-method
       * @jboss-net.wsdd-operation
       * @ejb.interface-method view-type = "remote"
       */
       public int[] testIntArray(){
       int i[] = {10,20,30};
       return i;
       }


      but on the C# site I can't figure out how to access the content of the array...

      ...
      int[] testint = stub.testIntArray();
      Console.WriteLine(testint[0]);
      ...


      This just shows a 0. What is the problem with this ?? testint.Length returns the correct array size of 3.

      Thanks
      matt