Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I define an array of custom types in WSDL?

I'm very new to WSDL, but what I'm trying to do is very simple. I have gotten a web service working with python's ZSI library, but am stuck defining a service which returns an array of a custom type.

In my WSDL I have the following:

<xsd:element name="ArtPiece">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="title" type="xsd:string" />
        <xsd:element name="year" type="xsd:string" />
        <xsd:element name="imageId" type="xsd:int"  minOccurs="0" />
        <xsd:element name="image" type="xsd:base64Binary"  minOccurs="0" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

If I try to add another element like ArtPieceArray that's defined by having an unlimited number of ArtPiece types, that seems to be invalid.

If, when I'm defining my message, I try to use ArtPiece[], that also seems to be invalid.

I'm using ZSI for the web service, and C# for the client. The client web service code is generated by wsdl.exe

Any suggestions?

like image 988
MStodd Avatar asked Feb 19 '10 03:02

MStodd


1 Answers

<xs:schema elementFormDefault="qualified" 
           targetNamespace="http://schemas.datacontract.org/2004/07/Foo" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:tns="http://schemas.datacontract.org/2004/07/Foo">
    <xs:complexType name="ArtPiece">
        <xs:sequence>
            <xs:element minOccurs="0" name="image" nillable="true" type="xs:base64Binary"/>
            <xs:element minOccurs="0" name="imageId" type="xs:int"/>
            <xs:element minOccurs="0" name="title" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="year" nillable="true" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="ArtPiece" nillable="true" type="tns:ArtPiece"/>

    <xs:complexType name="ArrayOfArtPiece">
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="ArtPiece" nillable="true" type="tns:ArtPiece"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="ArrayOfArtPiece" nillable="true" type="tns:ArrayOfArtPiece"/>
</xs:schema>
like image 163
Darin Dimitrov Avatar answered Nov 02 '22 11:11

Darin Dimitrov