Sean
Sean

Reputation: 223

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. i.e related to channel state. I cant find any documentation on the setting up the client.

Thanks very much.

Upvotes: 4

Views: 1695

Answers (1)

Sean
Sean

Reputation: 223

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

Upvotes: 3

Related Questions