简体   繁体   中英

How to return and array in a soap service?

and i want to return and array of buyers this is my xsd file, there is also the definition of buyer in the xsd file:

<xs:element name="getBuyerResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="buyer" type="tns:buyer" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="deleteBuyerRequest">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="id" type="xs:int" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="deleteBuyerResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="response" type="xs:boolean" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:complexType name="buyer">
    <xs:sequence>
        <xs:element name="id" type="xs:int" />
        <xs:element name="name" type="xs:string" />
        <xs:element name="lastname" type="xs:string" />
    </xs:sequence>
</xs:complexType>

i dont know how to write the request and response for all the buyers in the application.

I am using spring boot, java 7, maven, posgress,

Thanks

You can use the maxOccurs attribute. For example, to return any amount of buyer elements in your getBuyerResponse:

<xs:element name="getBuyerResponse">
   <xs:complexType>
      <xs:sequence>
         <xs:element name="buyer" type="tns:buyer" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
</xs:element>

Or to return a maximum of 8 buyer elements:

<xs:element name="getBuyerResponse">
   <xs:complexType>
      <xs:sequence>
         <xs:element name="buyer" type="tns:buyer" maxOccurs="8"/>
      </xs:sequence>
   </xs:complexType>
</xs:element>

Note that maxOccurs defaults to 1 if you do not specify it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM