I remember with ASMX there was an easy solution:
MyAsmxServiceClient serviceClient =
new MyAsmxServiceClient("http://myServiceLocation/myService.asmx");
How can achieve the same with WCF?
I remember with ASMX there was an easy solution:
MyAsmxServiceClient serviceClient =
new MyAsmxServiceClient("http://myServiceLocation/myService.asmx");
How can achieve the same with WCF?
On the same lines, binding = binding type you are using
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://localhost:8888/MyService");
MyServiceClient sv= new MyServiceClient(binding, address)
That's usually done in the app.config/web.config:
<system.serviceModel>
<client>
<endpoint
address="http://myServiceLocation/myService.asmx"
binding="basicHttpBinding"
contract="IMyServiceContract" />
</client>
</system.serviceModel>
or you could also do it programatically if you prefer.
Normally when you generate the client side proxy using the svcutil.exe it will also create a sample output.config
file containing all you need to setup the configuration.
UPDATE:
You could also provide names to your endpoints:
<system.serviceModel>
<client>
<endpoint
name="foo"
address="http://foo.com/myService.asmx"
binding="basicHttpBinding"
contract="IMyServiceContract" />
<endpoint
name="bar"
address="http://bar.com/myService.asmx"
binding="basicHttpBinding"
contract="IMyServiceContract" />
</client>
</system.serviceModel>
and then:
using (var client = new MyClientProxy("foo"))
{
var result = client.SomeMethod();
}