Developing Windows service using WCF - wcf

I have one requirement.
In our company each employee will submit some standard reports using internal portal.
If some employees not submitted report end of the day manager should get notified list of employees not submitted report.
I am using SQL Server database in which one table maintains records the employees submitting reports.
For this i want to use WCF client service.
This service will be installed on the server and client service should send email to Manager at specific time whoever not filled reports.
I know this is very basic requirement and i can do in Windows service. But I want to implement using WCF client service.
Can anyone help me how to do this task using WCF. And can you please refer some links.

I think you want to host the wcf service in windows service instead of IIS.
var serviceHost = new ServiceHost(typeof(YourService));
serviceHost.Open()
Open the service host in the onstart method of windows serice and close on onstop event. And copy the wcf config from wcf service project to windows service project and comment the configuration from wcf service project.

Related

Remote debug WCF services running under a custom IIS account

I want to remote debug an WCF service. The application pool that hosts the WCF service runs under an custom account. The custom account is a domain account.
In the 'Attach to Process' window in Visual Studio 2012 I have checked 'Show all processes from all users' but it only shows WCF services that are hosted under a built-in IIS account (like NETWORK SERVICE, etc.).
How can I remotely debug this service?
Assuming you've gone through this https://msdn.microsoft.com/en-us/library/y7f5zaaa.aspx, you may need to go through this https://msdn.microsoft.com/en-us/library/9y5b4b4f.aspx
HTH!
You are not seeing because it is not hosted in your application. You have to host the Remote WCF Service first. Add Service reference to add WCF to your app. Then right click WCFService.svc file to view WCF Service in browser to start the service. It will now be available to you and you can Attach the process.

Periodically run WCF method automatically

I have WCF hosted in IIS. There is a service method which gets the latest Db table record and do some work.
I want my web service to periodically cheks the database table and if there is new record deposited in the table then do the work.
I know how to handle this If my WCF hosted as windows service. But have no idea to do with IIS hosted WPF.
Please advice me.
if u need your wcf service to be invoked at some defined intervals, you can use Quartz Scheduler, where we can specify a particular task to be executed at defined intervals
pls check this link
http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/
It will basically be a Windows Service, with your WCF service reference added to it.
you can just use the Quartz API.

Deploying a wcf web service

I am new to web services. I have successfully created my WCF web service, now I want to consume it. The client to consume this is on a different machine. I am using Visual Studio 2012. The service that executes a stored procedure in SQL Server 2005.
How do I proceed to make the other party test the service?
you will have to add service reference to the service by right clicking your client application.

Consume WCF Service Hosted in a Windows Service

I wrote the WCF Service and hosted in windows service. I need to know how to consume this windows service in my client application.
Note:
I wrote Net pipe binding service.
Edit:
How can I write the client application for net pipe binding?
You need to do a few easy steps:
start your Windows service hosting your WCF service
from within Visual Studio (2008 or higher), right-click on a project node in the solution explorer and choose "Add service reference"
enter the URL where your service can be reached
That's about all there is, really. Visual Studio will go to your running service, get all the metadata it needs (assuming you've enabled a MEX endpoint for metadata exchange), and will create a client proxy class for you to use to connect your client to your service.
Marc
you need to use ChannelFactory to create a proxy, and then you can use the proxy to perform wcf tasks.
ChannelFactory<IWCFService> pipeFactory = new ChannelFactory<IWCFService>(
new NetNamedPipeBinding(),
new EndpointAddress("net.pipe://localhost/PipeWCFService"));
IWCFService pipeProxy = pipeFactory.CreateChannel();
pipeProxy.RunWCFServiceMethod();}
http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication
You can consume it like any other WCF service. The method used for hosting the WCF service is not relevant to the client side.
If you need details on how to actually build the client, let me know and i'll update the post.
Edit : Start here to learn how to build a WCF client.

How would you communicate a wcf service with a windows service?

Two weeks ago I needed a way to communicate a wcf service with a windows service running on the same computer. The windows service had to get data from a external source and share it with the wcf service (hosted in IIS) who had to give it when a client made a request. I chose to do that with ipc.
I done it and now the windows service is the ipc server and the wcf service is the ipc client. This goes well but I think I made a mistake doing this because to make it run right the windows service must to be executed with the ASPNET account, for this the ASPNET password account must be assigned and when I do that the IIS does not work correctly.
I am thinking on different alternatives, but in all of them the problem persists. Some ideas?
Edit:
What I needed was a system that made public, in a web service hosted in IIS, data gotten through telnet from another old system, what is a little unstable. How the response of this second system was slow I chose to put a process (the windows service) between the web service and the old system. The windows service had to save the data collected from the old system and when the wcf service asked it give it all at once through ipc.
Why does the windows service need to run as the ASPNET user? Is that because you're using an IPC connection that requires authentication from the caller?
Another alternative (if you have control over the windows-service code) would be to make that a WCF service as well (using a ServiceHost in the windows service). The IIS service could connect to the windows service using a NetTcp or NetNamedPipe binding if you need the IPC-like performance.
Why not just create another account with the same permission set of the ASPNET user which both the WCF service and your other service run under? That way, you have control over the password.
Ideally, the windows service should run as a WCF service, that way its easy for the client to communicate with it.
The next question is weather the 'client' needs to be a WCF service. If this client needs to serve other applications then it is appropriate, otherwise it may not be nessesary. I don't know enough about your system, so its up to you to decide what's best!