复杂类型在wcf wsdl中不可用

Ahm*_*fin 14 wcf wsdl

我已经创建了一个WCF服务,但是服务WSDL没有显示我的类(复杂类型).

以下是服务:

[ServiceContract]
public interface IFedexService
{
    [OperationContract]
    ShipmentReply CreateMultiFedExShipment(RxRdShipment shipment);

    [OperationContract]
    ShipmentReply CreateFedExShipment(RxRdShipment shipment);
}
Run Code Online (Sandbox Code Playgroud)

我的班级定义是:

[DataContract]
public class ShipmentReply
{
    [DataMember]
    public string ReferenceNumber { get; set; }

    [DataMember]
    public string MasterTrackingNumber { get; set; }

    [DataMember]
    public List<ReplyPackage> Packages { get; set; }

    [DataMember]
    public bool Response { get; set; }

    [DataMember]
    public RxNotification Notification { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我没有找到这ShipmentReply门课WSDL.我的问题是什么?

谢谢你,Arefin

mar*_*c_s 31

是的,这对WCF来说是正常的.默认情况下,WCF将仅显示WSDL本身中的操作 - 数据结构记录在链接到WSDL文件的XSD文件中.

我敢打赌,如果你看看你的WSDL,你会在WSDL的顶部看到类似的东西:

<xsd:schema targetNamespace="http://tempuri.org/Imports">
  <xsd:import schemaLocation="http://localhost:8000/HelloIndigo?xsd=xsd0" 
              namespace="http://tempuri.org/" /> 
  <xsd:import schemaLocation="http://localhost:8000/HelloIndigo?xsd=xsd1"  
              namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
  <xsd:import schemaLocation="http://localhost:8000/HelloIndigo?xsd=xsd2" 
              namespace="http://schemas.datacontract.org/2004/07/WCF_Simple_Service" /> 
</xsd:schema>
Run Code Online (Sandbox Code Playgroud)

这些是指向所需XSD文件的链接 - 在浏览器中键入URL,其中一个(很可能是编号最高的那个 - 但不一定是那个)将包含您的复杂类型定义.

在浏览器中尝试此URL(根据您的要求调整端口和实际URL):

http://localhost:8080/HelloIndigo?xsd=xsd2
Run Code Online (Sandbox Code Playgroud)

这应该为您的复杂类型提供XSD

这个功能在过去几年中引起了一些问题 - 一些客户端无法处理这种(100%正确和完美的)语法.所以在.NET 4.5中,WCF将有一个新的参数(...?singlewsdl)来输出你的整个WSDL,包括所有的XSD元素 - 请参阅WCF 4.5中的新功能?单个WSDL文件,以获取更多信息.