wcf windows service interaction - windows

I have a windows service in which i host a wcf service.
What is the best approach to control the windows service via the wcf service? I already created the interfaces for the wcf service, but I have no idea how to interact with the windows service's classes and functions.

just to check that I'm understanding your problem correctly - you want to run a wcf service, so you create a windows service to host it, and you want your desktop client to be able to control the windows service (that's hosting the wcf service) by talking to the wcf service?
If that's the case, what is it that you're trying to do with the windows service? In some of the work I've done, I've set up the server such that there's the windows service hosting all the wcf services I want to run, and in order to interact with that windows service remotely (e.g. starting/stopping/restarting) I have another service running on the server (usually baked into the Amazon instance image so it's running on every new server that gets brought up) which my remote client can talk to instead. That way I have a means to trigger a service restart on all my servers without having to manually connect/remote desktop to each server. Of course, the second wcf service is secured by some means so it can't be exploited easily.
Is that the sort of thing you're looking to do?

Related

Where to host WCF service for CRM Online 2016?

I have created a WCF service, which will be consumed by / called from CRM 2016 Online Case Form (using jscript/ajax call).
Where should I host the WCF service?
You are responsible for deciding where to host the service and configuring/programming for single sign-on (if you need security and want to avoid additional password prompts.)
The most logical place to run this would be in Azure: Deploying WCF Service on Windows Azure

How to call an already running windows service?

Is there anyway to call a windows service that's already running or a process to get info? What my goal is to find out if my windows service is an infinite loop or dead lock and see if it responds. So I want to be able to pass an argument from another program to a windows service and want it to to return a string or number. Is this possible? I can change the windows service to accommodate this. I am thinking of an event or something.
Note: I am not supposed to have the service write to a file or database.
You can host a WCF service in your Windows Service which you could call to get status information.
Here are a couple of links on doing that:
Can I host a WCF Service in a windows service?
How to: Host a WCF Service in a Managed Windows Service

non-IIS hosted WCF Services consumed over the internet connecting to back end Database over the internet

I am kind of new to system architecture. That is, all of my web apps have been relatively flat...two machines at the most running web client and database.
I have been handed the following architecture:
1 VMware machine will run the web application, an MVC 3 app.
1 VMWare machine will host the SQL Server database
1 VMWare machine will host the services.
The machine I'm confused about is the last one. From what I understand, the services project contains references to three other projects: the model, where the entity framework edmx resides, the entities project, which contains T4 templates that use the entity edmx file as input, and the business project which is where the actual business rules are implemented and the meat of the CRUD actions take place.
From what I understand, the intent is to not run an IIS WCF web services interface, but to make calls to WCF services (like those hosted in the MMC services snap in) on the machine over the internet. There is a deployment project in the solution for the services project but I don't know if it's configured properly. I think the idea is to just run the installer on the services machine and it will work.
My specific question is if there are any important things that I need to keep in mind when implementing, configuring, and deploying these services?
I'm kind of new to all of this. I was under the impression that you had to make calls to WCF services via IIS hosted endpoints and that you couldn't (or it at least was inadvisable) to make what amounts to RPC-like calls to machines over the internet.
Since you are new to WCF services, I suggest reading this MSDN article on Hosting and Consuming WCF services.
From what you describe, it looks like you are using Windows Service as a host for your WCF service.
The most common choice for a host is IIS because of its extensive features including self-starting services, ease of deployment, load balancing and so on.
Windows Service is a valid host, provided you can justify the question 'Why not IIS?'. Maybe, you need full control over the activation and lifetime of your WCF service. Not sure.
p.s. Ensure the account that your Windows Service runs under, has the minimum privileges.

Windows phone 7 - how to connect to remote services

I want to connect to remote machine using windows phone 7.5. Is there any inbuilt classes in .net for this.
For regular desktop application same can be done using ServiceController class. I am looking for the similar class for windows phone application.
ServiceController is used to control state of services on local or remote machine.
WP apps don't have a way of controlling remote or local services.
You would have to write SOAP or REST API for managing services and then connect WP app to those, but do make sure it is secured properly - you don't want to give access to service control to everyone.

Writing Windows service in WCF

I want to write windows service in wcf After searching a lot I only found were tutorials of writing webservice in wcf not windows service.
Can any one please provide a link to any tutorial which explains how to write windows service in WCF
Windows services are executables. WCF applications are, generally, web services, exposed over a URI. You can host a WCF application within a windows service, not the other way around.
To create a Windows service in C#, follow the step-by-step here. To make your Windows service WCF-enabled, if you will, create the System.ServiceModel.ServiceHost instance that will host your WCF service inside the OnStart() callback.
Good answers all of them. Just a quick note... implement your WCF service in a class library (dll) so you can then host it anywhere you like (IIS, Console App, or Windows Service).
I'd recommend starting from a console application, after your service works as expected, create a Windows Service, add a reference to you library and start the service (WCF) from there (Windows Service)
Edit: I just assumed you meant create a WCF service hosted as a Windows Service, if that's not the case please ignore my answer.
Create your WCF service as normal, create a Windows Service and then use ServiceHost to self-host the WCF service in your Windows Service. See this MSDN page for more information about self-hosting WCF services.

Resources