在SOAP中发送多个条目

时间:2012-12-04 10:27:36

标签: xml web-services soap nsurlconnection

我正在创建一个使用XML与SOAP Web服务通信的应用程序。我需要一次发送多个条目。 SOAP页面说我需要使用像这样的XML:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <InsertArrivaliOS xmlns="http://microsoft.com/webservices/">
      <GuestID>long</GuestID>
      <Key>string</Key>
      <NumberOfGuests>int</NumberOfGuests>
      <Table>string</Table>
      <Note>string</Note>
      <ArrivalDate>dateTime</ArrivalDate>
    </InsertArrivaliOS>
  </soap:Body>
</soap:Envelope>

我想发送2个InsertArrivaliOS节点。有可能做这样的事吗?

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <InsertArrivaliOS xmlns="http://microsoft.com/webservices/">
      <GuestID>long</GuestID>
      <Key>string</Key>
      <NumberOfGuests>int</NumberOfGuests>
      <Table>string</Table>
      <Note>string</Note>
      <ArrivalDate>dateTime</ArrivalDate>
    </InsertArrivaliOS>
<InsertArrivaliOS xmlns="http://microsoft.com/webservices/">
      <GuestID>long</GuestID>
      <Key>string</Key>
      <NumberOfGuests>int</NumberOfGuests>
      <Table>string</Table>
      <Note>string</Note>
      <ArrivalDate>dateTime</ArrivalDate>
    </InsertArrivaliOS>
  </soap:Body>
</soap:Envelope>

1 个答案:

答案 0 :(得分:1)

您可以将InsertArrivaliOS包装在带有列表的其他元素中。定义模式时,可以添加另一个类型,然后将其作为一系列无限制的InsertArrivaliOS元素添加。 所以你的xml代码看起来像这样:

 <soap:Body>
   <listArrival xmlns="http://example.org">
    <InsertArrivaliOS xmlns="http://microsoft.com/webservices/">
      <GuestID>long</GuestID>
      <Key>string</Key>
      <NumberOfGuests>int</NumberOfGuests>
      <Table>string</Table>
      <Note>string</Note>
      <ArrivalDate>dateTime</ArrivalDate>
    </InsertArrivaliOS>
<InsertArrivaliOS xmlns="http://microsoft.com/webservices/">
      <GuestID>long</GuestID>
      <Key>string</Key>
      <NumberOfGuests>int</NumberOfGuests>
      <Table>string</Table>
      <Note>string</Note>
      <ArrivalDate>dateTime</ArrivalDate>
    </InsertArrivaliOS> 
   </listArrival>
  </soap:Body>

看到这个想法? 或者您无法修改架构?