Tag: wcf

WCF:什么是ServiceHost?

正如我目前正在学习使用WCF服务,我经常遇到互联网上提到使用WCF服务时使用ServiceHost教程。 这个ServiceHost究竟是什么? 在我当前的项目中,我正在使用WCF服务,并从我的应用程序中引用它,并且每当我想从应用程序中使用它时,我只是像这样实例化其ServiceClient : new MusicRepo_DBAccess_ServiceClient(new InstanceContext(instanceContext), customBinding, endpointAddress); 然后从那个实例访问我的web方法( OperationContract s)(显然在使用方法之前打开它,然后用Open和Close ) 我的WCF服务是我的IIS中的主机,我只需从我的应用程序访问.svc实例化ServiceClient 。 那么ServiceHost为什么和在哪里使用?

WCF服务与asp.net mvc应用程序

我已经开始使用asp.net MVC和传统的方式,我想保持我的数据访问层在WCF服务。 我怎样才能实现使用asp.net MVC? 脚本 我开始在asp.net MVC中显示,插入和编辑数据的testing应用程序。 我通过添加“ADO.Net实体数据模型”成功创build。 所以,现在如果我想在WCF服务中移动这个数据访问层,也就是像GetData(),UpdateData(),CreateNewData()这样的WCF服务,我该如何实现呢?

WCF服务引用生成自己的契约接口,不会重用我的

我的第一个问题,所以希望它是适合的: 共享接口程序集 – 我有一个有共享接口的“共享”程序集,我们称之为IDocRepository 。 它标有[ServiceContract] ,有几个[OperationContract]标记的方法。 WCF实现程序集 – 我有两个WCF服务项目,每个引用共享程序集,每个实现该接口作为WCF服务。 消费者组装 – 最后,我有一个“客户”项目,也引用了共享程序集,并引用了每个WCF服务。 但是,在使用者程序集中生成的服务引用来自接口的自动生成版本: public partial class ExampleClient : System.ServiceModel.ClientBase<SomeNamespace.ExampleSvcRef.IDocRepository>, SomeNamespace.ExampleSvcRef.IDocRepository { 我所期望的 我希望这两个引用会自动inheritance我定义的接口,消费者/客户端程序集也是引用。 有点像重用它提供的参数和返回types的类,而是用于服务接口。 为什么 所以我可以创build一个服务引用代理的实例,并将其转换为我的接口types。 所以我可以每次手动修改生成的代码,但应该有更好的方法…? (编辑:我确实有'在引用程序集中重用types'和'为所有服务引用select的所有引用程序集中的重用types'选项)

WCF服务maxReceivedMessageSize basicHttpBinding问题

我似乎无法让我的WCF服务接受大量的数据发送到它。 我为客户端configuration了maxReceivedMessageSize,可以接收大量数据,这不是问题。 它将数据发送到服务。 我试图configuration服务,但没有任何运气。 这是我的web.config: <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true"/> </system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false" /> <serviceDiscovery /> </behavior> </serviceBehaviors> </behaviors> <services> <service name="Service.IService"> <clear /> <endpoint binding="basicHttpBinding" bindingConfiguration="MessageSizeBasic" contract="Service.IService" /> </service> </services> <bindings> <basicHttpBinding> <binding name="MessageSizeBasic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding> </basicHttpBinding> <webHttpBinding> <binding […]

WCF – 合同名称不能在合同列表中find

我对WCF比较陌生。 不过,我需要创build一个将数据公开给Silverlight和AJAX客户端应用程序的服务。 为了达到这个目的,我创build了以下服务来作为概念certificate: [ServiceContract(Namespace="urn:MyCompany.MyProject.Services")] public interface IJsonService { [OperationContract] [WebInvoke(Method = "GET", RequestFormat=WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] List<String> JsonFindNames(); } [ServiceContract(Namespace="urn:MyCompany.MyProject.Services")] public interface IWsService { [OperationContract(Name="FindNames")] List<String> WsFindNames(); } [ServiceBehavior(Name="myService", Namespace="urn:MyCompany.MyProject.Services")] public class myService : IJsonService, IWsService { public List<String> JsonFindNames() { return FindNames(); } public List<String> WsFindNames() { return FindNames(name); } public List<string> FindNames() { […]

用于.NET 4.0的Svcutil.exe?

我正在尝试使用svcutil.exe为服务生成代理类,但是当我使用/reference选项来引用为.NET 4.0构build的程序集时,出现错误。 无法加载文件或程序集或其某个依赖项。 此程序集由比当前加载的运行时更新的运行时构build,无法加载。 所以看来我使用的是旧版本的svcutil.exe。 我正在使用"C:\Program Files\Microsoft SDKs\Windows\v7.0A这是我能find的最新版本。是否有更新的版本在我应该使用的地方?

WCF:如何从ServiceHost获取端点列表?

我可以使用ServiceHost.AddServiceEndpoint添加端点。 我怎样才能得到终点列表?

WCF服务如何将事件提交给客户?

我想知道在WCF中是否有事件处理的方法。 我遇到过WCF中的callback,但我想在WCF中做事件处理。 我的要求就像我想提高事件给特定的客户端,而不是所有的客户在WCF中使用事件处理,我也想保持会话。 我已经在WCF中看到了处理callback的发布者/订阅者模型,但是这个模型发布给所有已经订阅的客户端,但是我只想发布给选定的客户端。 我认为可以使用WCF中的事件来完成。 客户端 : public class Callbacks : IServiceCallback { public void CallToMyClient(string name) { this.CallToMyClient(name); } } protected void Page_Load(object sender, EventArgs e) { Callbacks callback = new Callbacks(); ServiceClient client = new ServiceClient(new InstanceContext(callback)); client.SubscribeClient(); client.DoSomeWork(); }

WCFunit testing

如何unit testingWCF服务? 任何第三方工具可用?

HTTP错误404.17 – 未find

在VS 2008中,我可以运行.svc但生产IIS 7我不能。 我得到这个错误。 我正在使用x64胜利。 我跑 C:\Windows\Microsoft.NET\Framework\v2.5.0.30319>aspnet_regiis.exe -i Start installing ASP.NET (4.0.30319). ……………………. 和 C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -i The error indicates that IIS is not installed on the machine. Please install IIS Finished installing ASP.NET (2.0.50727). 但它是一样的。 我运行VS 2008.应用程序池:NET framweork是2.0。 我启用32位应用程序 Error Summary HTTP Error 404.17 – Not Found The requested content appears to be script and […]