3

When I create a new "WCF Service Application" in Visual Studio and right-click Service1.svc, I can choose "View in Browser". A web browser appears showing http://localhost:50311/Service1.svc, which says

Service1 Service

You have created a service.

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe http://localhost:50311/Service1.svc?wsdl
...

The service somehow seems tied to Visual Studio itself, since the web page becomes inaccessible if I close the solution. What's going on? I don't have a web server installed, and I didn't (knowingly) start the service. What is the source of the displayed web page, and why is it on port 50311? Can the page be customized?

Makoto
  • 104,088
  • 27
  • 192
  • 230
Qwertie
  • 16,354
  • 20
  • 105
  • 148
  • It sounds like VS did exactly what you told it to do. Perhaps you could describe what you *want* to do, and somebody can probably suggest how to get there. – Greg Hewgill Mar 10 '11 at 23:32
  • Mainly I just want to understand what's going on. If I run with Ctrl+F5 I get the root of a web server calling itself "ASP.NET Development Server 9.0.0.0". I didn't even realize that WCF services normally ran inside a web server, and I didn't know VS came with a web server although it is obvious when I thought about it (otherwise how would it support ASP.NET out-of-box? it's just that I've never used ASP.NET before.) – Qwertie Mar 11 '11 at 00:06
  • My actual goal is to make a server in a Windows Service that communicates with a client process on the same machine or a different machine. The communication protocol is unimportant, except that I'd like to minimize the size of messages, in case the communication link is slow, and I need to support "push" messages from the server to the client. As well as running as a Windows Service, it should also be able to run as a standalone executable. – Qwertie Mar 11 '11 at 00:11
  • Anyway, what I honestly expected was that a WCF service would just be a normal .exe application that opens a port and waits for clients. Clearly it is something else. It compiles to a DLL and then apparently Visual Studio starts a web browser that somehow detects and loads the service. Are Visual Studio WCF projects inherently web-based? Can I make a WCF app as a standalone exe, no web server? – Qwertie Mar 11 '11 at 00:25
  • I think you may be getting confused by the terminology here - you've created a "Web Service" while it sounds like you really want a "Windows Service". A Windows Service is an .exe file that does some special stuff at startup to be able to run in the background on a Windows machine, even when no user is logged on. Does that sound right? – Greg Hewgill Mar 11 '11 at 00:26
  • Yes, but I thought I wanted to use WCF (seeing how complicated WCF is to set up at http://msdn.microsoft.com/en-us/library/ms734712.aspx is making me think twice though). Note that I selected "WCF Service Application" as my project type--this name includes no hint that it is web-based. – Qwertie Mar 11 '11 at 00:40
  • This related question shows that you may find "WCF Service Library" is a better choice for you: [What is the difference between WCF Service application and WCF Service library?](http://stackoverflow.com/questions/1204365/what-is-the-difference-between-wcf-service-application-and-wcf-service-library) – Greg Hewgill Mar 11 '11 at 00:54
  • A WCF Service Library compiles to a DLL. How is one supposed to run it outiside VS, then? Maybe I should ask another SO question. – Qwertie Mar 11 '11 at 17:18
  • Sounds like a plan. I'm sure there's an answer to that, I just don't know what it is. :) – Greg Hewgill Mar 11 '11 at 17:46

1 Answers1

4

What you're seeing is the development web server that starts when you run a debugger instance of a project that requires a web server. (WCF, ASP.NET).

The port 50311 is determined by your project settings (most likely random, but you can specify).

The page for a .svc file is not meant to be customized. Since the service is waiting for a caller, that default page simply tells you that it's running properly.

Keep in mind that WCF offers several binding options that use various protocols (HTTP, TCP). Depending on the protocol that you choose, you will have to host in either IIS, a Windows Service or elsewhere. By default, new services will adopt a binding that works in IIS.

Check out Introduction to Building Windows Communication Foundation Services

Justin Skiles
  • 9,373
  • 6
  • 50
  • 61