How to prevent WCF proxy from redirecting later?

I use basicHttpBinding for my WCF service and have a message inspector that sets up a response code to redirect under certain circumstances. I believe that the WCF proxy (generated by svcutil) automatically tries to redirect. How to prevent this?

Thanks Priya

+3
source share
2 answers

Can you reference the service contract assembly from your client application? If so, you can get rid of the generated service link and just start the proxy server at runtime using ChannelFactory.

For instance:

// 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);

IMyServiceContract - , MyRequestType MyResponseType - , , , ( ).

0

All Articles