我正在使用一个网络服务,我有这个来自 wsdl:
<xs:complexType name="Person">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="PersonAddresses" type="ns:PersonAddress" />
</xs:sequence>
</xs:complexType>
来自 xsd:
<!--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 集合并向其中添加地址对象。
...
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>
那么我做错了什么......所需的格式是
<PersonAddress>
<Address>
...
</Address>
<Address>
...
</Address>
</PersonAddress>
感谢您的任何意见