简体   繁体   English

WCF Web服务客户端与Castle windsor

[英]WCF web service client with Castle windsor

I am using .net 3.5. 我正在使用.net 3.5。 and castle 2.5.2. 和城堡2.5.2。

I have a WCF web service. 我有一个WCF Web服务。

I am trying to build a client (mvc 2.0 website) that uses castle, to inject the proxy. 我正在尝试构建一个使用castle的客户端(mvc 2.0网站)来注入代理。

So I generated a proxy using svcutil. 所以我使用svcutil生成了一个代理。 I put the proxy in my client website and registered it with the container like so: 我把代理放在我的客户端网站上并将其注册到容器中,如下所示:

container.Register(
            Component.For<IMyWCFServiceProxy>()
                .ImplementedBy<WCFServiceProxy>());

Then injected the proxy interface into my class that calls the service. 然后将代理接口注入我调用该服务的类中。 All fine so far. 到目前为止都很好。

However, when i called the web method on the proxy i got: "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. " 但是,当我在代理上调用web方法时,我得到了:“通信对象System.ServiceModel.Channels.ServiceChannel不能用于通信,因为它处于Faulted状态。”

So i wondered, do i have to add any more information when i register the client proxy with the container. 所以我想知道,当我向容器注册客户端代理时,我是否必须添加更多信息。 ie related to channel state. 即与渠道状态有关。 I cant find any documentation on the setting up the client. 我找不到有关设置客户端的任何文档。

Thanks very much. 非常感谢。

My problem was that I was missing a reference to the end point when i registered the proxy. 我的问题是,当我注册代理时,我错过了对结束点的引用。 The service is working now after this change: 此更改后,该服务现在正在运行:

    Component.For<IMyWCFServiceProxy>()
                .ActAs(DefaultClientModel
                           .On(WcfEndpoint.FromConfiguration("wsHttpEndpoint"))).
                ImplementedBy<MyWCFServiceProxy>());

Although, I have been reading this article over the weekend, and like the look of this. 虽然,我周末一直在阅读这篇文章,并且喜欢这个样子。

http://favcode.net/browse/using_castle_dynamic_proxy_to_create_a_wcf_proxy_via_channelfactory http://favcode.net/browse/using_castle_dynamic_proxy_to_create_a_wcf_proxy_via_channelfactory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM