c# - 如何在 WSDL 中定义一组自定义类型?

标签 c# python web-services soap wsdl

我是 WSDL 的新手,但我想做的事情非常简单。我已经获得了一个使用 python 的 ZSI 库的网络服务,但我无法定义一个返回自定义类型数组的服务。

在我的 WSDL 中,我有以下内容:

<xsd:element name="ArtPiece">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="title" type="xsd:string" />
        <xsd:element name="year" type="xsd:string" />
        <xsd:element name="imageId" type="xsd:int"  minOccurs="0" />
        <xsd:element name="image" type="xsd:base64Binary"  minOccurs="0" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

如果我尝试添加另一个元素,如 ArtPieceArray,它是通过无限数量的 ArtPiece 类型定义的,这似乎是无效的。

如果,当我定义我的消息时,我尝试使用 ArtPiece[],那似乎也是无效的。

我将 ZSI 用于 Web 服务,将 C# 用于客户端。客户端web服务代码由wsdl.exe生成

有什么建议吗?

最佳答案

<xs:schema elementFormDefault="qualified" 
           targetNamespace="http://schemas.datacontract.org/2004/07/Foo" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:tns="http://schemas.datacontract.org/2004/07/Foo">
    <xs:complexType name="ArtPiece">
        <xs:sequence>
            <xs:element minOccurs="0" name="image" nillable="true" type="xs:base64Binary"/>
            <xs:element minOccurs="0" name="imageId" type="xs:int"/>
            <xs:element minOccurs="0" name="title" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="year" nillable="true" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="ArtPiece" nillable="true" type="tns:ArtPiece"/>

    <xs:complexType name="ArrayOfArtPiece">
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="ArtPiece" nillable="true" type="tns:ArtPiece"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="ArrayOfArtPiece" nillable="true" type="tns:ArrayOfArtPiece"/>
</xs:schema>

关于c# - 如何在 WSDL 中定义一组自定义类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2293873/

相关文章:

c# - 如何增加来自 c# 应用程序的 mysql 连接的连接超时?

web-services - ArrayOfXXX 类超出数组类型的 soap 输入参数

java - java 和 .net 之间的 WS-A

python - django ajax选择添加按钮

web-services - 调用使用 Windows 凭据保护的 ASMX 服务

c# - 使用 C# 驱动程序从 MongoDB 集合上的文本查询中检索相关性有序结果

c# - Windows Phone 8.1 中的 WriteableBitmap.Pixels

c# - 自定义类,将子项添加到子列表并抛出异常

python - 如何在 pandas DataFrame 中每 5 行后添加新 id,

python - 阻止 ftplib 下载正在进行的文件?