Title: .NET multi dimensional array
What you can do is modify the wsdl as follows:
 
Replace the following:
 
   <complexType name="ArrayOfArrayOf_xsd_string">
    <complexContent>
     <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[][]"/>
     </restriction>
    </complexContent>
   </complexType>
with this:
 
   <complexType name="ArrayOf_xsd_string">
    <complexContent>
     <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
     </restriction>
    </complexContent>
   </complexType>
   <complexType name="ArrayOfArrayOf_xsd_string">
    <complexContent>
     <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="impl:ArrayOf_xsd_string[]"/>
     </restriction>
    </complexContent>
   </complexType>
 
This will tell .NET to use an array of arrays (a jagged array) instead of a 2 dimensional array.
 
If you place the 2-D array in a class (bean), axis will generate the latter code for it, so .NET will be able to understand it without manual modification of the wsdl.  Unfortunately, there is a bug in axis which prevents it from deserializing 2D arrays properly if they are class properties (http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14033).  If your axis web service is only sending them back to a .NET client, this shouldn't cause you any problems, but you won't be able to send one from the client to the server.
 
I find it strange that axis generates the type information inconsistently, depending on whether it is a bean property or not.  Is there any reason for this, axis developers?
 
One other thing, I am having trouble getting .NET to read in even single dimensional arrays when they are class properties, so the solution of putting it into a class might be a dead end too.  I'm still investigating this.
 
Let me know how you get on.
Martin Jericho
 
----- Original Message -----
Sent: Wednesday, October 30, 2002 9:19 AM
Subject: .NET multi dimensional array

I have a Java web service published to Axis that returns a 2 dimensional String array.  It take no parameters:
public String[][] getTwo()
{
        String[][] multiArray = new String[2][3];
        multiArray[0][0] = "One1";
        multiArray[0][1] = "One2";
        multiArray[0][2] = "One3";

        multiArray[1][0] = "Two1";
        multiArray[1][1] = "Two2";
        multiArray[1][2] = "Two3";

        return multiArray;

}

I generate the WSDL and it looks great.
I generate Java clients with WSDL2Java.
Execute this code and it works great.

I then go into .NET
If I call a method that returns a one dimensional String array, then .NET works good.

But, the return method in .NET of getTwo() only returns a 'single' dimension array.  I cannot cast it to anything else.

If I leave it at a single dimension, and run it, .NET give a message saying it does not suppor it.
Is this true?
It is saying I should use an array of arrays instead.

----------------.NET error---------------------------------------
Error consulting: System.InvalidOperationException: There is an error in XML doc
ument (5, 5). ---> System.ArgumentException: SOAP-ENC:arrayType with multidimens
ional array found at <getTwoReturn xmlns=''>. Only single-dimensional arrays are
 supported. Consider using an array of arrays instead.
Parameter name: value
   at System.Xml.Serialization.XmlSerializationReader.ParseArrayType(String valu
e)
   at System.Xml.Serialization.XmlSerializationReader.ReadArray()
   at System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(Str
ing name, String ns, Boolean elementCanBeType, String& fixupReference)

----------------------------The WSDL looks like this:-----------------------
- <wsdl:types>
- <schema targetNamespace="http://localhost:8080/WSB/soap/TestRama" xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ArrayOf_xsd_string">
- <complexContent>
- <restriction base="soapenc:Array">
  <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]" />
  </restriction>
  </complexContent>
  </complexType>
  <element name="ArrayOf_xsd_string" nillable="true" type="impl:ArrayOf_xsd_string" />
- <complexType name="ArrayOfArrayOf_xsd_string">
- <complexContent>
- <restriction base="soapenc:Array">
  <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[][]" />
  </restriction>
  </complexContent>
  </complexType>
  <element name="ArrayOfArrayOf_xsd_string" nillable="true" type="impl:ArrayOfArrayOf_xsd_string" />
  </schema>
  </wsdl:types>


Reply via email to