I am working on a windows service that acts as a medium between a web application and a standalone client side program. In a nutshell: Before submitting a form on my web application, I want it to be encrypted by my client side standalone program. The medium of communication has to be the windows service.
My question is: How do I call a C# function in my service through JS? (This function will help me relay data back and forth between the website and the standalone application)
I was successfully using an applet to act as the medium before but I have shunned that idea as many security issues are being plotted off late.
You can self host a REST based service in a Windows Service. For example using the NancyFx framework http://nancyfx.org/. You can then make an ajax call using localhost as the endpoint, this would mean that the service MUST be installed and running on any clients which access it.
Also just a query, why are you doing your own encryption client side? You can encrypt the communications to the server using SSL and then do whatever encryption you require server side. Is this some design that is being imposed on you?
Does it have to be a Windows service?
You could write a WCF service that you host inside a Windows service. There's an article on MSDN about how to do that (http://msdn.microsoft.com/en-us/library/ms733069(v=vs.110).aspx) and there are many more on the Web.
You cannot call a function defined in a Windows service directly, you have to expose it to the outside world using some kind of endpoint, like the way WCF does.
Related
I have an application in WPF c# which will run on client machine. Another application (maybe some kind of service) on a particular server will be running all the time and will wait for any incoming message from the client app. As soon as the server receives a request from any of the client application, it triggers a command line process and also responds to the client about the staring info(whether it was successful or not) and as well as when the command line process is finished it again responds to the calling client application that it got finished.
I am new to in this area.
So my question is should I use normal windows service or Web service or WCF?(Some kind of link to a demo project will really help). Any other suggestion are also welcomed.
You did not mention if your clients will be outside of your firewall or with in the same intranet. We have intranet scenario, and we use WCF service that communicates with WPF based applications over the internal network. WCF provides Duplex feature which enables two-way client server communication using an easy to implement programming model. I recently wrote an article on this and it can give you a head start for the WCF way.
However, WCF does not have the best support for callbacks over the internet and you may have to look in to effectively using it in your case. But if it is intranet, then my suggestion is surely to go for the WCF way. Hope it helps.
We have a Website (hosted somewhere) and C# Application (which is installed on my PC). I need to accomplish the following:
Customers fill up the form on the website, i.e. the task is "created"
C# Application immediately receives this data from the website and process it
The result is sent back to the server, i.e. "task accomplished" message
The website updates status regarding this task
How do you build this kind of link between the website and an app?
In the past I've used TCPListener to communicate between two C# apps. I'm also familiar with the UDPlistener and such.. Will this knowledge be of some use? The website is going to be build on the PHP.
Some tips and advises are appreciated. Thanks.
Your website should not be dependant on an application running on your home or office PC, so the site should publish some kind of service or feed. You can make this a webservice, which is quite easy in PHP.
You then consume this service from your C# application. Make it request the new tasks regularly, by polling the service. When you've received new tasks you process them in your application, and when you've done what you want to do you update the tasks on your server using another webservice call.
All this can be done using some sort of queue in the database that backs your website.
Make the C# application a web service may be a windows host depending on your requirement
you can the webservice from php as shown here Using PHP to call a WCF web service with multiple bindings
If you have the control over your web host and your client, you could try setting up a WCF service with duplex contracts which allows the server to callback your client. Your PHP site can call the WCF service and it can in turn notify the client. Else you will have to go with the polling method where the Desktop client has to poll the web service to get the list of pending tasks.
I am new to WCF (Just a day or 2). I am planning to make an application having Client/Server
WCF Service (On Server hosted as windows service):
Will invoke some commands using (Process.Start())
Will send some information from my database
Questions:
What WCF binding should I use? WsDualhttp or netTCP (Please elaborate if you can)
Does WCF works with SqlServer + EF 4.1
Server UI:
This will primarily will be used to
Start ot stop the above service
Change Address (localhost to [My Ip address]) and Port
Show status of service (Running or dead)
Questions:
How can I Change the address and port of my WCF service from this UI (it will be a different project and hence different config file).
Client App:
Used to issue commands to WCF service.
Get to know if the service is running or dead.
Receive status messages for task completion or faults.
Also, can the windows installer be combined to install ServerUI + WCF Service + Windows service?
WCF Service
Here are a couple links on choosing the right binding. Based on the scenario you're describing, I'd go with the netTCP.
C# - WCF - inter-process communication
Choosing the right WCF binding
WCF and SQL Server are independent of each other, so I wouldn't expect any problems using the Windows service to interact with your database.
I'd suggest reading up on how to start a process from a Windows service.
Server UI
I would suggest hosting another WCF service in your Windows service for interacting with your Server UI. You can use the netNamedPipeBinding since this communication channel will always be local, i.e., on the same box. So your Windows service will host two WCF services - one for the external communication with the client and one for the local communication with the configuration UI.
Installer
Yes, the Windows installer can be used, but that might be overkill for what you're describing. Of the Server UI, WCF Service, and Windows service, the only one that absolutely requires installation is the Windows service. The others could theoretically run simply by copying the assemblies to the target system. You might consider having the Windows service install itself via command line. That way you could get away with a self-extracting executable using software like WinZip. This might be less heavyweight than a formal install. If you go this route, have a look at the step-by-step here.
Ha a look at WCF duplex services:
http://msdn.microsoft.com/en-us/library/ms731064.aspx
Why do you want to have a interface to an windows service? And if you have access to IIS7 and WAS, I would recommend to use it instead of self-hosting in windows service.
Here is a good starting point for WCF Configuration Management:
http://msdn.microsoft.com/en-us/library/ff650534.aspx
Yes, you can use windows installer.
Cheers
--Jocke
I'm trying to give functionality to the user where they can remotely control the client on their system from a mobile device or laptop.
What I have created is a WCF Console application which holds the contracts etc. and starts the server.
Now here's the thing, if I create a HTML page I can't do anything with it to make it communicate with the server and then the client as I'll need the HTML page to make call a method on my WPF client to initiate an action.
Has anyone had any experience with this, I think almost there with my solution it's just this wall that I've hit.
Thanks
If your looking for a way to call WCF server functions from a webpage then use Ajax enabled WCF service. Read here: http://www.codeproject.com/Articles/33234/A-beginner-s-guide-for-consuming-a-WCF-service-in
What would be the best way to transfer a string across a network from a windows mobile device(so .net) to a .net app running on a pc on the same wifi network?
Would normal sockets work or would i use something like a webrequest?
The client can be any version of .net.
Thanks
For application there is no matter what type of connection is used, because it is incapsulated inside net-related classes.
On desktop you may use
TcpListener http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx
HttpListener http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
WCF
Web Service
ASP.NET Handler
These classes allows you to map some URL like http://{PC-name}/somepath to code executed by your applcation.
On mobile device you may use some classes allows you to make request using that URL. Also if your desktop application publish web service or WCF service, you may add reference to this service to mobile application and get strongly-typed interface to operate with desktop application. It is preferred way as for me.