简体   繁体   中英

WCF web service client with Castle windsor

I am using .net 3.5. and castle 2.5.2.

I have a WCF web service.

I am trying to build a client (mvc 2.0 website) that uses castle, to inject the proxy.

So I generated a proxy using 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. "

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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