0

我正在创建一个使用 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>
4

1 回答 1

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>

看到这个想法了吗?还是您无法修改架构?

于 2012-12-04T10:32:37.843 回答