tags:

views:

142

answers:

1

Hi,

Let's say that I have created a WCF proxy from a WCF service (which is configured with wsHttpBinding) using Add Service (in Visual Studio 2008).

Later I want to use basicHttpBinding so I'll go and change the WCF service to use basicHttpBinding. But what about the WCF proxy? Can I just change this via Web.config or do I need to create the WCF proxy again from the WCF service via Add Service?

Thanks

+1  A: 

It depends :-)

If you already have all the bindings in place when you do the Add Service Reference the first time around, then your client side proxy configuration will include all the bindings, and you can basically switch from using one to the other without any reconfiguration or anything. Each client endpoint (which has one specific binding) should have a name, so you can pick and choose:

MyServiceClient client = new MyServiceClient("endpointname");

However, if you add the second binding to your service after you've added the service reference to your client side code, then yes - you need to upgrade your service reference. To do so, open the Service References node in your solution explorer in the client side project, right click on that service reference you're interested in, and choose Update Service Reference from the context menu.

Update Service Reference

This will pull down any new information about additional bindings and stuff from the server side and update your client side config accordingly.

Once that's done, you should have multiple client side endpoints in your config and you can create whichever one of those is appropriate for your current needs based on the client endpoint name.

marc_s
Thank you for the answer. One clarification. So if I specify by default two bindings (basicHttpBinding and wsHttpBinding) for a WCF service in the Web.config (under the bindings element), do I also need to specify two endpoints or can I just use only one endpoint (and just change its binding property to basicHttpBinding or wsHttpBinding in the WCF proxy without generating a new proxy)?
WCFDeveloper
if you do it in config, you have to have two endpoints - one for basicHttpBinding, the other for the wsHttpBinding.
marc_s
Ok, got it! Thanks again and have a nice day! :)
WCFDeveloper