添加Web服务引用但无法在对象浏览器中看到它,并且未生成客户端类

时间:2015-12-11 16:00:44

标签: c# asp.net .net web-services wcf

我试图在VS Express 2013中向我的控制台应用添加一些wcf服务。我成功地将所有服务添加到Web References。对于来自第三方的某些服务,我可以在对象浏览器中看到它们并生成客户端类。对于我创建的服务,我无法在对象浏览器中看到它们,也没有生成客户端类。我读过这些(https://social.msdn.microsoft.com/Forums/en-US/d2bc41df-20ee-4fc1-9807-1cd21dee37f6/can-add-web-service-reference-but-cannot-see-it-in-object-browser-or-use-itWhy, when adding a service reference in VS2010, is the client class not generated?)和其他帖子,但仍然无法使其发挥作用。以下是有问题的服务的代码:

IFileProviderService.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.IO;
using System.ServiceModel.Web;

namespace MyServices
{
    [ServiceContract]
    public interface IFileProviderService
    {
        [OperationContract]
        [WebGet(UriTemplate = "/AppInstaller/{userID}/{fileName}/{os}")]
        Stream AppInstaller(string userID, string fileName, string os);
    }
}

FileProviderService.svc.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.IO;
using System.ServiceModel.Web;
using System.ServiceModel.Activation;

namespace MyServices
{
    [AspNetCompatibilityRequirements(RequirementsMode =     AspNetCompatibilityRequirementsMode.Allowed)]
    public class FileProviderService : IFileProviderService
    {
        public Stream AppInstaller(string userID, string fileName, string os)
        {
        ......

        }
    }
}

Reference.cs

#pragma warning disable 1591

namespace ServiceTest.MyFileProviderService {

}

#pragma warning restore 1591

此服务正在运行且运行正常。 任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

问题得到解决。事实证明,服务必须是'basicHttpBinding'才能从客户端访问。见this document