views:

1304

answers:

0

I'm using gsoap to generate an XML SOAP parser and WSDL grammar, and was wondering what is the recommended way to express a static array that is both fast to parse and generates a corresponding WSDL that passes all the validation tests (like Eclipse WSDL Validator or NetBeans Validate XML).

If I use this input into gsoap:

struct ns__ArrayOfSomeInts { xsd__int ints[10]; };

I get this resulting WSDL (within definitions/types/schema tags):

  <complexType name="ArrayOfSomeInts">
   <sequence>
     <element name="ints" type="ns:Array10Ofxsd__int" minOccurs="1" maxOccurs="1" nillable="true"/>
   </sequence>
  </complexType>
  <complexType name="Array10Ofxsd__int">
   <complexContent>
    <restriction base="SOAP-ENC:Array">
     <attribute ref="SOAP-ENC:arrayType" WSDL:arrayType="xsd:int[]"/>
    </restriction>
   </complexContent>
  </complexType>

Running this through NetBeans "Validate XML" gives this error:

  • ERROR: src-resolve: Cannot resolve the name 'SOAP-ENC:Array' to a(n) 'type definition' component.

Eclipse WSDL Validator gives these two errors:

  • WS-I: (BP2108) An Array declaration uses - restricts or extends - the soapenc:Array type, or the wsdl:arrayType attribute is used in the type declaration.
  • WS-I: (BP2122) A wsdl:types element contained a data type definition that is not an XML schema definition.

I can clean up these errors by changing the gsoap code to define a dynamic array as such:

struct ns__ArrayOfSomeInts { int __size; xsd__int *ints; };

(with corresponding WSDL:)

  <complexType name="ArrayOfSomeInts">
   <sequence>
     <element name="ints" type="xsd:int" minOccurs="0" maxOccurs="unbounded"/>
   </sequence>
  </complexType>

But now I've lost the performance gains of using a static array. Is there another way to keep performance while maintaining compliance?