Web services 无法使用类型为泛型集合数据类型的方法生成wsdl文件。?

Web services 无法使用类型为泛型集合数据类型的方法生成wsdl文件。?,web-services,proxy,wsdl,svcutil.exe,Web Services,Proxy,Wsdl,Svcutil.exe,我有一个web服务,它有一个参数为Collection(字节)类型的方法。 当我尝试使用wsdl命令生成代理时,数据类型被转换为一维字节数组 因此,我考虑使用addas服务引用创建wsdl文件,该文件的类型为Collection(of byte),但即使我将Collection type指定为Collection.objectModel,参数的数据类型仍然是一维字节数组 是否有任何方法可以执行此操作,或者需要手动更改代理文件中的内容。您需要指定集合类型: svcutil/t:代码 /ct:Sys

我有一个web服务,它有一个参数为Collection(字节)类型的方法。 当我尝试使用wsdl命令生成代理时,数据类型被转换为一维字节数组

因此,我考虑使用addas服务引用创建wsdl文件,该文件的类型为Collection(of byte),但即使我将Collection type指定为Collection.objectModel,参数的数据类型仍然是一维字节数组


是否有任何方法可以执行此操作,或者需要手动更改代理文件中的内容。

您需要指定集合类型:

svcutil/t:代码 /ct:System.Collections.Generic.List`1


.

我还创建了一个web服务,其中一个方法返回字节集合数组。 我附上示例代码及其生成的wsdl。希望这能对你有所帮助

public byte[][] GetPDFs(String searchQuery)
    {
List<Byte[]> list = new List<byte[]>();
// DO YOUR WORK
 return list.ToArray();
}
生成的代理代码(wsdl.exe或使用add reference)如下所示:


如果您需要进一步的帮助,请告诉我。

我确实尝试过在高级选项中使用添加服务引用,但在wdsl中,数据类型仍然表示为tns:ArrayOfBase64Binary,因此在创建代理时,它被创建为字节数组而不是字节集合。WSDL将始终显示ArrayOfWhatver,因为泛型类型不是一个可以用XSD和WSDL表示的概念。当您从WSDL生成代码时,您可以选择是否生成数组、列表等。在webservice的情况下,它们看起来就像它的设计一样。
    <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://TDS.elixir.com/">
      <s:element name="GetPDFs">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="searchQuery" type="s:string" />
          </s:sequence>
        </s:complexType>

      </s:element>
      <s:element name="GetPDFsResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetPDFsResult" type="tns:ArrayOfBase64Binary" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="ArrayOfBase64Binary">

        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="base64Binary" nillable="true" type="s:base64Binary" />
        </s:sequence>
      </s:complexType>
    </s:schema>
  </wsdl:types>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetPDFs", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public byte[][] GetPDFs(string searchQuery) {
        object[] results = this.Invoke("GetPDFs", new object[] {
                    searchQuery});
        return ((byte[][])(results[0]));
    }