.NET Core 和ASP.NET Core 已经可以调用WCF 服务。

环境要求:

VS2015 Update 2 +VS2015 Tooling + .NET Core SDK

下载地址:

https://www.microsoft.com/net/core

已经安装可以忽略。

安装扩展

打开VS2015 在 工具-》扩展和更新 联机中搜索 WCF Connected Service

.NET Core 调用WCF 服务

 

然后下载安装。安装完成后重启VS2015.

创建WCF服务

新建一个wcf 服务,里面添加一些方法。

.NET Core 调用WCF 服务

INETCoreService.cs

    [ServiceContract]
    public interface INETCoreService
    {

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        [OperationContract]
        List<string> GetList();

        // TODO: 在此添加您的服务操作
    }


    // 使用下面示例中说明的数据约定将复合类型添加到服务操作。
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }
View Code

相关文章: