Using WCF Contracts to operate WPF Client - c#

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

Related

Client-Server communication- Looking for best solution

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.

How to Angular.js controller from C#

I have Windows service written in C# that basically acts as a timer to fire an event. When the service fires I need to call a Angular.js controller passing variable(s) and receive a PDF file back as the response. I'm new to Angular so any help would be appreciated.
Angular lives on the client side in the web browser (well, typically anyway) so if you want to communicate to it from your C# service you need to find a way to send and receive information between your server (running the service) and the client browser.
How you can go about this depends on your project's needs, but for timed events you're probably best off using websockets to perform this communication. If you're working in C# you might want to check out SignalR for your backend.

Connect iPhone app to Desktop app

In my C# project I have this function.
public void DoStuff()
{
Console.WriteLine("I'm doing something...");
}
In the application this can be called normally through an event, such as a button press. DoStuff();
I want to be able to call this function from an iPhone application, wirelessly.
I plan to do this by adding creating a TCP server in the C# Application that will listen for incoming connections. Then I can use my iphone to connect to my local ip, and the open port number, and then send a string of text to a console window, which will activate the function.
I understand this is not the best way to do this, but it is the only idea I have...
Some other things I have heard of are WCF? What is this and how can I use this to achieve my goal?
I know this question is quite general, but my programming experience is quite minimal.
Yes you can also use WCF which is natively in c# providing Webservice.
You can send soap message from iphone , let WCF do the left things and get soap response from WCF.
This is not a specific solvable problem and is opinion based. However, I'd look to web api instead of wcf.
You can run web app without IIS using the self host packages on nuget.
That gives you a http endpoint that is easier to interact with than wcf which invariably ends up being SOAP based. From IOS you're going to find this easier.
Just a pointer.

Calling a C# windows service function through javascript

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.

communication between the website and C# winforms application

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.

Categories

Resources