2

I am new to the world of WCF and MVC. Currently I have a MVC3 ASP application and a WCF service app exposing some services. I want access this service from MVC3 ASP app. As I know either this can be done by adding the Service Reference to ASP project or by generating proxy class from WCF service and add proxy class to ASP app.

My question: Is it the right way I am going (as said above). If so which method is better (adding service reference or generating proxy class and adding it manually)?

Pavan
  • 1,023
  • 2
  • 12
  • 25
  • if you want to adhere by the SOA(Service Oriented Architecture) go by the way of generating the proxy class and stub code stuff from the WCF Service... Adding Service Ref is kind of a silver bullet method – Dakait Mar 05 '13 at 06:28
  • I recommend Channel Factories. See related thread [here.][1] [1]: http://stackoverflow.com/questions/1698275/wcf-channelfactory-vs-generating-proxy – Manish Jain Mar 06 '13 at 02:07
  • I recommend Channel Factories. See related thread [here.][1] [1]: http://stackoverflow.com/questions/1698275/wcf-channelfactory-vs-generating-proxy – Manish Jain Mar 06 '13 at 02:08
  • I recommend Channel Factories. See related thread [here.][1] [1]: http://stackoverflow.com/questions/1698275/wcf-channelfactory-vs-generating-proxy – Manish Jain Mar 06 '13 at 02:14

1 Answers1

1

It is a lot easier to use add service reference. Add service reference basically means that you are asking visual studio to do the job that you would have done if you were generating it manually with default settings. If you don't have any reason not to go the easier way, then my advice is to use add service reference.

Olav Nybø
  • 11,454
  • 8
  • 42
  • 34
  • Thanks for reply. I would like to know, if you are going to choose other way (by adding proxy class manually); then where will you add proxy class in MVC3 ASP app? Is it inside controllers part? – Pavan Mar 05 '13 at 06:10
  • 1
    It depends on the size of your application and what other assemblies you have. You either have to add the proxy class to the assembly where you are going to call it, or add a reference to the assembly where it is located from the assembly you are calling it from. – Olav Nybø Mar 05 '13 at 06:40
  • Actually I am calling that wcf service on a button click from ASP UI. So its click will be posted to controller method. Inside controller I can use proxy and call wcf service. So is it a good way to add proxy class to the controller directly? because I just have a .cs file of proxy not a assebly to reference it. – Pavan Mar 05 '13 at 08:00