我使用Web服務時,我有這個從WSDL的陣列創建SOAP請求複雜類型
<!--Complex Type for PersonAddress-->
<xs:complexType name="PersonAddress">
<xs:sequence>
<xs:element name="Address" type="Address" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<!--Complex Type for Address-->
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="Addr1" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Addr2" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="City" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="State" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Zip" type="xs:string" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
使用生成的代理,我創建PersonAddress的Collection並將Address對象添加到它。
...
var convertedAddresses = new PersonAddress[addressesToCounvert.Count];
for (int i = 0; i < addresses.Count; i++)
{
convertedAddresses[i] = ConvertAddress(addresses[i]);
}
person.PersonAddresses = convertedAddresses;
...
當我提交請求時,它看起來像這樣
<PersonAddress>
<Address>
...
</Address>
</PersonAddress>
<PersonAddress>
<Address>
...
</Address>
</PersonAddress>
所以我在做什麼wrong..the需要的格式將
<PersonAddress>
<Address>
...
</Address>
<Address>
...
</Address>
</PersonAddress>
感謝任何輸入
您可以更改'maxOccurs =架構中的PersonAddress/Address是否爲= maxOccurs =「unbounded」=「1」 – RichardTowers
謝謝!這似乎是問題。 – Chris