none
Convert WCF REST template RRS feed

  • Question

  • Hi

    I have used the WCF REST template to create my first service and it works very well using the localhost. I would like to further test this serviceby converting it to a console application so I can turn it the outside world. I think that when testing is complete I would run it as a windows service. 

    Could some one help with advice on how to convert it to a console application please?

     

    Thanks.

    Paul


    Paul
    Tuesday, July 19, 2011 7:14 PM

Answers

  • Hello, one of the main reason to use ASP.NET routing is to hide the .svc extension in an IIS hosted REST service. If you're using console host, you can specify the URI using UriTemplate (which is part of the WebGet/WebInvoke attribute). So you can ignore the routing code.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    Windows Azure Technical Forum Support Team Blog
    • Marked as answer by PAUL stanley Thursday, July 21, 2011 9:50 AM
    Thursday, July 21, 2011 2:42 AM

All replies

  • It more simple than you think - create a console application, copy all the code and configuration to it, add the references to system.servicemodel and system.servicemodel.web and create some code to start a new ServiceHost object.

    The part about starting a host can be found here:

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

    (The parent branch in the MSDN also contains an article on how to host the service in a windows service)

     


    Please mark posts as answers/helpful if it answers your question. Senior Consultant on WCF, ASP.NET, Siverlight, and Entity Framework. Author of Microsoft's Official WCF 4 Course. Co-author of the Microsoft HPC/Azure burst whitepaper. Visit my blog: http://blogs.microsoft.co.il/blogs/idof
    Wednesday, July 20, 2011 7:07 AM
  • Thanks very much for your help. How about the global.asax file which contains code about RegisterRoutes does this need to go in its own module ?
    Paul
    Wednesday, July 20, 2011 10:50 AM
  • Oh, register routes cannot be used in a console application - it is a part of asp.net routing.

    How did you config the route? did you add your own custom logic to it? or did you just use it remove the ".svc" extension from the url?


    Please mark posts as answers/helpful if it answers your question. Senior Consultant on WCF, ASP.NET, Siverlight, and Entity Framework. Author of Microsoft's Official WCF 4 Course. Co-author of the Microsoft HPC/Azure burst whitepaper. Visit my blog: http://blogs.microsoft.co.il/blogs/idof
    Wednesday, July 20, 2011 10:52 AM
  • On the rest template there was n't a .svc file just web.config,global.asax and the service1.vb and another class .vb file used for testing.
    Paul
    Wednesday, July 20, 2011 12:13 PM
  • For creating a Windows Service, you can create the project of type 'Windows Service' directly. Why need to create a REST service, change to console and change to Windows Service ?
    Malayalam SMS Website http://smsmallu.brinkster.net
    Wednesday, July 20, 2011 12:26 PM
  • I am learning the rest way of wcf so it was a natural starting plave (rest template). I guess that you can't convert it.
    Paul
    Wednesday, July 20, 2011 9:44 PM
  • Hello, one of the main reason to use ASP.NET routing is to hide the .svc extension in an IIS hosted REST service. If you're using console host, you can specify the URI using UriTemplate (which is part of the WebGet/WebInvoke attribute). So you can ignore the routing code.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    Windows Azure Technical Forum Support Team Blog
    • Marked as answer by PAUL stanley Thursday, July 21, 2011 9:50 AM
    Thursday, July 21, 2011 2:42 AM
  • Ok thanks will have a look at the routing because I obviously don't understand that part as yet. 

    Thanks for your help.


    Paul
    Thursday, July 21, 2011 9:49 AM