Choose between which type of WCF proxy generation path we should take?

106 views Asked by At

I am new to WCF service. I am aware about three ways to generate proxies.

  1. Using Service reference
  2. Using SvcUtil
  3. Using ClientBase

But I am confused in which case I should use which type. In my case I have to generate proxies for third party service for which I don't have service code. I don't want to use add service reference because it gives me following issue. Mentioned in this stackoverflow question. So I want to use clientBase. But I think I cannot use it without using service reference. I am pretty much confused when should we choose which kind of proxies.

1

There are 1 answers

4
AudioBubble On

In my case I have to generate proxies for third party service for which I don't have service code.

I will have multiple apps using this service.

In that case you are better off using SvcUtil because it can generate a single library that all of your projects can use, even if they are .NET libraries. After it is generated you can always go in and tweak it.

Add service reference on the other hand is fine for a single .exe but as you have discovered, is annoying for multiple apps as you need to repeat the process and you end up with multiple definitions of WCF types that is just going to increase maintenance.

Just be sure to leave WCF client config in the app.config of your applications and not your app.config of your class library (as the former may not be read).

If your vendor had followed "WCF the Manual Way… the Right Way" it would have made your life easier.

SOAP purists would argue however that the only thing the vendor provides is a SOAP WSDL XML file from which you are required to generate your types anyway. (sadly, the default behaviour in .NET is back-to-front)