Any WCF Client Proxy Generator for channels manage?

336 views Asked by At

Which best ChannelFactrory wrapper would you recommand? I`m searching for a simple one that will handle the channel creation process and reopen in when needed.

1

There are 1 answers

0
tom redfern On

The channel creation process is already very simple with ChannelFactory.

I guess if you pre-generate a service proxy using svcutil that would generate a wrapper for you. But I don't think the wrapper would be any simpler to use.

// Create service proxy on the fly
var factory = new ChannelFactory<IMyServiceContract>("NameOfMyClientEndpointInConfigFile");
var proxy = factory.CreateChannel();

// Create data contract
var requestDataContract = new MyRequestType();

// Call service operation.
MyResponseType responseDataContract = proxy.MyServiceOperation(requestDataContract);

In the above example, IMyServiceContract is your service contract, and MyRequestType and MyResponseType are your data contracts, which you can use by referencing the assembly which the service also references (which defines these types).