Run WCF Service from Metro App Client - wcf

I have a WCF service which is hosted on localhost, and I have a Metro app which consumes the service. Currently, for using the service, I have to separately run the service in a separate instance of Visual Studio, and after that I run the Metro App client.
Is there any way I can set the client app to start running the service as soon as the app starts, and not again and again start the service separately before the app?
Thanks in advance.

You should host the WCF service using full-blown IIS instead of IIS Express within Visual Studio. You can change this via the Web Tab of the project properties. By using IIS instead of IIS Express, the WCF service will always be listening for requests.

AFAIK, Windows 8 does not support (yet) the communication on localhost from a Metro App to a WCF service. The reason it works in VS is because they did allow this for development use. If you want a continuously running service available, use another (virtual) machine to host it separately.
Alternatively, check out this question on SO for more information about this issue.

Related

Which kind of VS project to use for WCF-Service hosted on internal Server

I need urgent help and have many questions. I will start by asking what kind of Ms-Vs project should i use (Wcf-Application or Wcf-library) to create a wcf-service, which will be hosted on a local server in my company and will be consumed by a windows phone 7 application.
Hope to find an answer!
If you want to host your service on localhost using web browser or local IIS server this WCF application is appropriate.
If you want to host your application on console host or window service then WCF library is appropriate.

wcf service on windows 2003 server - works as server but not as a consumer/client

It is a very simple wcf service. Since my original wcf service didn't work there I decided to create one test service. Basically I'm using the default method GetData(int).
I hosted this service on windows 2003 server. It works well when I consume it from a different machine. I use a windows forms test application to consume this service. When I run this forms app on the same ws2003 server and attempt to consume the service on the same server it throws the following error:
There was no endpoint listening at http://...
I created another wcf client using asp.net, also silverlight, nothing works.
Basically, it looks like it can't consume any wcf service.
I couldn't figure out what could be the issue.
Basically, the machine had McAfee antivirus installed and was blocking http communication to aspnet_wp.exe.
The full path is c:\windows\microsoft.net\framework\v4.0.30319\aspnet_wp.exe
Everything works fine after unblocking this specific exe.

can I expose a WCF service from an application runing in visual studio(with F5, run)?

If I run a WCF application which exposes a service in visual studio, is it possible to consume the service from an asp.net application running on another computer? How can I determine the address of the WSDL published by the WCF service in order to add a reference to it in the ASP.NET application?
If your service is an ASP.NET application and you are hosting it with the built-in development server, refer to Kalus's answer. However, if you have IIS installed locally, you can reconfigure your project settings so that the application is hosted by IIS for debugging instead of the built-in development server.
If you are writing a standalone WinForms or Console application, then the responsibility will be on you to select an endpoint and binding, whereas with an ASP.NET application, those parameters will come from IIS or the Dev server (the protocol will always be HTTP/HTTPS, and the port number will be set by IIS or randomly generated by the Dev server). So in a standalone application, you will have to configure which binding (basicHttp, wsHttp, netTcp, etc.) and an appropriate hosting endpoint (http://hostname/MyService or net.tcp://hostname:port/MyService). But yes, if the service is hosted by a standalone application, it will be accessible from other computers.
Refer to this overview here: http://msdn.microsoft.com/en-us/library/ms731758.aspx
According to #Kent Boogart's comment below, the asp.net development server can only be used for local requests. So you will need to configure your web service to run in IIS if you want to call it from another machine.

Deploying a TCP based WCF service, that's hosted in a Windows service

I've finished writing a WCF service that uses TCP. It is meant to run on a Windows 2003 Server, which doesn't have WAS available, so I've written a Windows service to host my WCF service. It works great on my development machine.
Now, how do I get these two services onto the Windows 2003 Server? Do I just copy the WCF service there and that's it? I would think it would probably be best if I put it into some specific location, but where would that be? And then the hosting Windows service, how do I deploy that to the Windows 2003 Server?
You should have a service deployment project that you've used in the Dev area.
It will be the same technique.
Example of creating a service in c# from codeproject
put it in program files\Your Service

Is it true that WCF are either console apps or run under IIS?

Is it true that a WCF either runs as a console application that you have to manually start OR under a more traditional IIS application (like a website or webservice)
you can start a WCF host process in a:
Windows Forms App
Console App
Windows Service
IIS 6 (Only HTTP hosting)
IIS 7 - WAS (All bindings supported)
Each of them has advantage or disadvantages. This page gives great information about hosting options: http://msdn.microsoft.com/en-us/library/bb332338.aspx.
EDIT: No, that is not quite true.
Those are two hosting options for WCF. There are others.
orig answer:
you can actually execute a wcf service everywhere, where you can execute managed code.
i've seen wcf services running inside sql server, wpf apps, windows services and even one running on a linux box on mono.
There is a class ServiceHost defined in WCF that allows you to host a service in any application like so:
using (ServiceHost host = new ServiceHost(typeof(MyService))
{
host.Open();
WaitForClose();
host.Close();
}
IIS running in Windows XP SP2+, Vista, 2003 or 2008 can host WCF services.
Yes, that's correct... you can also host them as a Windows Service
Part of the objective of WCF is to free you up from limitations on where the service is running. You can also use Windows Activation Service (WAS) for Vista and Windows Server 2008.
I have a WCF service that needs to run as a service in IIS 7.
The problem is that in order for it to start I need to manually invoke it through the browser e.g. http://site/myservice.svc.
Is there a way to have IIS call out and start the service host / wcf service when the application pool is restarted?
My preference would be to avoid a windows service and go with IIS / WAS