views:

402

answers:

3

I have a WCF service ( Let's say WCFService1 ) is deployed on two remote machines. Since the same service is deployed on two different machines they have common interface and common methods exposed.

WCFService1 is deployed on Machine1 and Machine2.

To consume WCF service from client machine, I have created a client app:

  1. I have added a design time reference of WCF service (WCFService1 )( with the help of URL http://11.12.25.23/WCFService/Service1.svc).

  2. Now I can invoke the methods exposed in the service. Up until now its fine...

Now my question is If I have to update client at run time with same service hosted in different machine with different URL ( Let's say http://12.12.24.24/WCFService/Service1.svc), How can I do that?

At present I am doing this:

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://12.12.24.24/WCFService/Service1.svc");
MyServiceClient serviceClient = new MyServiceClient(binding, address);

but whenever I use to invoke the method exposed in the service I got binding mis match error.

A: 

I'd suspect, that if you look in your web.config file on Machine1, you'll see that the binding there is WSHttpBinding (or something different than BasicHttpBinding). If you change it to BasicHttpBinding (assuming that is what you really want), you'll remove this error.

codekaizen
Thanks! it is resolved
Ashish Ashu
Feel free to accept this as the answer. ;)
codekaizen
A: 

Have you tried invoking your client first?

eg:

MyWCFClient client = new MyWCFClient();
client.EndPoint.Address = new EndpointAddress("http://somewhere:888/here.svc");
Wayne
A: 

How is your service configured? Show us your server-side and client-side config!

Binding mismatch means you're either not using the same binding, or some vital parameter on the binding is different - there must be something configured wrong - so show us the config!

Marc

marc_s