none
Create WFC service in an existing Winform Application RRS feed

  • Question

  • Hello all,

    I am working on a Winform application, with a SQL database, and today I would like to create a mobile app which takes data from this application. So I need to create a Web service, but I really begin with that.

    I have created a WFC service thanks to these tuto https://www.youtube.com/watch?v=JiUbKUZN4p4, https://www.youtube.com/watch?v=ZdT5JiIoUCw, and that works well. I am able to connect to the data.

    The problem, now, is that I don't manage to access to data of my server. Of course, I think that I need to deploy or publish the WFC service on the server, but I don't know how to do that and I have not found it on the web. 

    So I have two questions on this subject :

      - Do the WFC service need to be delivered directly with the Winform application ?

      - In the tutorials, we always need to launch the web service by running the project in Visual Studio. So if I deploy it on a server, is it always running or do I need to start it manually ?

    I hope my questions are clear enough.

    Thank you very much for your help !

    Regards,

    Friday, June 13, 2014 9:45 AM

Answers

  • The problem, now, is that I don't manage to access to data of my server. Of course, I think that I need to deploy or publish the WFC service on the server, but I don't know how to do that and I have not found it on the web.

    Nope, if that WCF Web service is running on IIS, which you should have done, and it is acccessable, then you don't deploy anything.

    So I have two questions on this subject :

      - Do the WFC service need to be delivered directly with the Winform application ?

    Nope, the WCF client software needs to consume the WCF Web service in code, which will put the WCF config information in an app.config. The WCF information needs to be copied to an app.config in the Windows form/exe project.

      - In the tutorials, we always need to launch the web service by running the project in Visual Studio. So if I deploy it on a server, is it always running or do I need to start it manually ?

    This tells me that you have not created a virtual directory for thye WCF Web service on IIS. If you have done that, then the WCF Web service is always running on IIS and it is avalibale for usage.

    http://www.codeproject.com/Articles/550796/A-Beginners-Tutorial-on-How-to-Host-a-WCF-Service

    If you go to the WCF Web service project in VS, right-click the project,  go to Properties. go to the Web tab, then you can create a virtual directory, that will deploy your WCF Web service to IIS. You can do that and skip some of the steps in the above link. Findout through a browser how you can give the URL of the Web service in a browser. And if the WCF Web service page shows, then you no the service is alive and running on IIS.

    Friday, June 13, 2014 9:06 PM
  • Actually, in all tutorials, the link to access to the service is always : http://localhost...

    Localhost means the Loopback IP is being used, which mainly being used in a development environment. IIS is running local machine. You  The traffic never leaves the local machine.

    http://compnetworking.about.com/od/workingwithipaddresses/g/127_0_0_1_def.htm

    //Localhost or 127.0.0.1 can be used, because they mean the same thing something that pertains to the local machine.

    http://computer.howstuffworks.com/internet/basics/question549.htm

    You have 127.0.0.1 that points back to the local machine,  and the local machine has a remote IP too.

    The remote IP allows other machines in a network it doesn't matter if it's a local area network LAN or wide area network WAN/Internet to communicate with each other over a network. So the IP of the remote machine that is hosting the WCF Web service must be known by the WCF client application.

    So the //localhost or //1270.0.1 would not be used by the WCF client. It would be //192.168.1.2 if that was the assigned IP by a DHCP server on a LAN form the computer, or it could be 169.2.77.22 if that was the IP being assigned to a machine that was hosting the WCF Web service over the Internet.

    So you have to know the remote IP of the machine that is hosting the WCF Web Service and change the URL away form //Loacalhost or 127.0.0.1 to a remote IP a machine is using the WCF client side application through the app.config in your case of the exe project must know the remote IP of the machine hosting the service.

    So how I can open the service from another computer ?

    http://msdn.microsoft.com/en-us/library/bb386386.aspx

    What is going to be produced in the app.config for the exe project is all the configuration stuff needed to communicate with the WCF service from the WCF client, and it's all going to be pointing to localhost if you point the Add Service Reference in VS to the locally running WCF Web Service on IIS. YOu move that exe to a another machine, then things in the app.config for the remote communications must be changed away from //localhost to the remote IP of the machine hosting IIS and the WCF Web Service.   

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/06e05f5f-9424-44e3-9c19-c2c28ddcab8c/is-it-true-that-endpoints-within-the-appconfig-in-the-client-override-those-in-development?forum=wcf

    Take note on the above link, because if you take that WCF client exe program and deploy it to a machine, then the programname.exe.config must be deployed to the same location as the programname.exe.

    Tuesday, June 17, 2014 10:26 PM

All replies

  • The problem, now, is that I don't manage to access to data of my server. Of course, I think that I need to deploy or publish the WFC service on the server, but I don't know how to do that and I have not found it on the web.

    Nope, if that WCF Web service is running on IIS, which you should have done, and it is acccessable, then you don't deploy anything.

    So I have two questions on this subject :

      - Do the WFC service need to be delivered directly with the Winform application ?

    Nope, the WCF client software needs to consume the WCF Web service in code, which will put the WCF config information in an app.config. The WCF information needs to be copied to an app.config in the Windows form/exe project.

      - In the tutorials, we always need to launch the web service by running the project in Visual Studio. So if I deploy it on a server, is it always running or do I need to start it manually ?

    This tells me that you have not created a virtual directory for thye WCF Web service on IIS. If you have done that, then the WCF Web service is always running on IIS and it is avalibale for usage.

    http://www.codeproject.com/Articles/550796/A-Beginners-Tutorial-on-How-to-Host-a-WCF-Service

    If you go to the WCF Web service project in VS, right-click the project,  go to Properties. go to the Web tab, then you can create a virtual directory, that will deploy your WCF Web service to IIS. You can do that and skip some of the steps in the above link. Findout through a browser how you can give the URL of the Web service in a browser. And if the WCF Web service page shows, then you no the service is alive and running on IIS.

    Friday, June 13, 2014 9:06 PM
  • Hello,

    Sorry for this late answer. And thank you for all these information. I understand well better now. I will try once again with the VS project of the link that you give me, expecting that it works ! 

    Thanks !

    Regards,

    Monday, June 16, 2014 8:26 AM
  • Hello,

    After doing some tests, there is something that I can't understand and I think that's why I am not manage to deploy a WCF service on IIS server.

    Actually, in all tutorials, the link to access to the service is always : http://localhost...

    I have added a new website in the IIS manager, with my VS project and the .svn file, but all that are in my sql server. So how can I connect to the WCF service from another computer. I mean, everything is on SQL Server, and works well if I open on IE : localhost, but of course if try to open the file .svn from a computer (not the server) it does not work.

    So how I can open the service from another computer ?

    Thank you !

    Regards,

    Tuesday, June 17, 2014 9:57 AM
  • Actually, in all tutorials, the link to access to the service is always : http://localhost...

    Localhost means the Loopback IP is being used, which mainly being used in a development environment. IIS is running local machine. You  The traffic never leaves the local machine.

    http://compnetworking.about.com/od/workingwithipaddresses/g/127_0_0_1_def.htm

    //Localhost or 127.0.0.1 can be used, because they mean the same thing something that pertains to the local machine.

    http://computer.howstuffworks.com/internet/basics/question549.htm

    You have 127.0.0.1 that points back to the local machine,  and the local machine has a remote IP too.

    The remote IP allows other machines in a network it doesn't matter if it's a local area network LAN or wide area network WAN/Internet to communicate with each other over a network. So the IP of the remote machine that is hosting the WCF Web service must be known by the WCF client application.

    So the //localhost or //1270.0.1 would not be used by the WCF client. It would be //192.168.1.2 if that was the assigned IP by a DHCP server on a LAN form the computer, or it could be 169.2.77.22 if that was the IP being assigned to a machine that was hosting the WCF Web service over the Internet.

    So you have to know the remote IP of the machine that is hosting the WCF Web Service and change the URL away form //Loacalhost or 127.0.0.1 to a remote IP a machine is using the WCF client side application through the app.config in your case of the exe project must know the remote IP of the machine hosting the service.

    So how I can open the service from another computer ?

    http://msdn.microsoft.com/en-us/library/bb386386.aspx

    What is going to be produced in the app.config for the exe project is all the configuration stuff needed to communicate with the WCF service from the WCF client, and it's all going to be pointing to localhost if you point the Add Service Reference in VS to the locally running WCF Web Service on IIS. YOu move that exe to a another machine, then things in the app.config for the remote communications must be changed away from //localhost to the remote IP of the machine hosting IIS and the WCF Web Service.   

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/06e05f5f-9424-44e3-9c19-c2c28ddcab8c/is-it-true-that-endpoints-within-the-appconfig-in-the-client-override-those-in-development?forum=wcf

    Take note on the above link, because if you take that WCF client exe program and deploy it to a machine, then the programname.exe.config must be deployed to the same location as the programname.exe.

    Tuesday, June 17, 2014 10:26 PM
  • Hello,

    I finally found the problem... In my IIS server, web service was not "autorized". I don't know what has been changed but now it works !!!

    I have now one last problem :). Actually I have tried to create a Function which make the sum of 2 numbers, which are in entries of the function and it works.

    But now, when I try to take data from my sql server database, I have an issue.

    First, the connection seems to work because when I launch WCF Test Client, I have all the data 

    

    But After that, when I run the program which consume the WCF, I have an error :

    The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

    I try to learn more about the real issue but impossible to find.

    Can it be a problem from my WCF service, or about the program?

    If you need any more details, I can say more :)

    Thanks a lot !

    Rgds,

    Wednesday, June 25, 2014 2:33 PM