Click here to Skip to main content
15,887,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,


Objective: I am trying to pass a user defined message from a website to a windows service running on a different server.

I have just been introduced to Windows Communication Foundation and there is ALOT here to it, so I would appreciate some clarification and additionally some advice. However, this looks to be the best way to communicate between websites and windows services. I have been reading several different articles on WCF and I’m a little confused on something. Basically, it seems like there is two different ways to do this.

One method seems to be creating a new WCF item inside my solution.

Or another way seems like all you have to do is add the <ServiceContract()> and <OperationContract()> tags in the classes of my already existing windows service and I’m able to call these methods from my Website like they’re part of Website’s project.

VB
Imports System.ServiceModel

<ServiceContract()> _
Public Class Test

<OperationContract()> _


I feel like that’s too easy and I’m not that lucky. So I’m going to assume that option one is how I’m going to have to proceed. Can anyone confirm this? And could anyone briefly explain to me how I could use this WCF item to relay messages between a Website and a Windows Service?
Posted
Comments
Karthik. A 9-Jul-12 14:58pm    
You cannot just call a windows service from your web application. A windows service is essentially controlled by the operating system under which it runs. Depending on the design of the service of the service, it may run at a specific time or at fixed intervals. So, One way I could immediately think of to pass data between the 2 is writing the user defined to a database from the web application. Then when the service runs, it could check the database to see if it has to take care of anything and then act on that (in this case it would be the user defined data).
Sergey Alexandrovich Kryukov 9-Jul-12 15:54pm    
Well, strictly speaking, the term "call" is only about a call to a function, method, procedure, property or an operator. But if one to talk about "remote calls", you can self-host WCF in a Windows Service, and then the remote object can be "called" by some server-side code of the Web application through a service contract...
--SA
Karthik. A 9-Jul-12 21:45pm    
That's an interesting way of implementing this Sir! Not sure I have heard of self-hosting wcf in a windows service. Will check it out!
Sergey Alexandrovich Kryukov 11-Jul-12 15:14pm    
If you only need general purpose purely custom WCF application, self-hosting is the best way. After all, why would one carry IIS or something of it is not really needed?
--SA

1 solution

I have used this to communicate with a SMPT server, to send e-mails. If I remember correct, you should set up the WCF on you server site page, with the operation contract and service contract. Then you should add a service reference in you web site location.

Thats all I could say from the top of my head...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900