无法将SOAP数组绑定到C#集合

时间:2019-04-15 14:38:10

标签: c# wcf asp.net-core soap

我正在为WSDL / SOAP端点实现与.NET Core兼容的客户端。

我得到的响应具有以下结构:

<?xml version="1.0" encoding="iso-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:account">
  <SOAP-ENV:Body>
    <ns1:readAvailableEventIdsResponse xmlns:ns1="http://tempuri.org/">
      <errors xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[0]"></errors>
      <response xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:EventId[2]">
        <item xsi:type="tns:EventId">
          <id xsi:type="xsd:string">1000</id>
          <description xsi:type="xsd:string">First Event</description>
        </item>
        <item xsi:type="tns:EventId">
          <id xsi:type="xsd:string">1001</id>
          <description xsi:type="xsd:string">Second Event</description>
        </item>
      </response>
    </ns1:readAvailableEventIdsResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

但是,我的客户端没有序列化响应集合。这是我的模型定义:

[MessageContract(WrapperName = "readAvailableEventIdsResponse")]
public class ReadAvailableEventIdsResponse
{
    [MessageBodyMember(Name = "errors", Namespace = "", Order = 1)]
    public StringArray Errors { get; set; }

    [MessageBodyMember(Name = "response", Namespace = "", Order = 2)]
    public EventIdArray Response { get; set; }
}

[CollectionDataContract(Name = "Array", Namespace = "http://schemas.xmlsoap.org/soap/encoding/", ItemName = "item")]
public class EventIdArray : List<EventId> { }

[DataContract]
public class EventId
{
    [DataMember(Name = "id")]
    public string Id { get; set; }

    [DataMember(Name = "description")]
    public string Description { get; set; }
}

但是,当我调用服务端点(使用定义为here的“自定义消息编码器”东西配置)时,我的EventIdArray为空。

我在做什么错了?

0 个答案:

没有答案
相关问题