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.
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.
I am a newbie developer to WCF and Windows services. I do know c#. The scenario requires various custom applications running on Windows 7 to call methods in another application. It is a client/server relationship, all running on the same computer. The server must be able to notify each client (one at a time) when a specified condition occurs.
I need to develop the server code only.
Would the following be an acceptable solution:
Make the server a windows service that uses WCF. The server could notify the clients by using a different named pipe for each client ?
Thank you...any suggestions would be appreciated.
Just use duplex communication over tcp/named pipes/msmq/http (WSDualHttpBinding) channel.
AFAIK you need two ports (in/out) for duplex over http
I would ditch wcf altogether. Although as Brian says, you can use the duplex bindings, these are complicated at best.
If it's all going to run on the same computer, why do you even need client/server? Just build a single client which does everything you need.
That is a acceptable solution and should work fine.
Other option for consideration (in the spirit of learning) is creating a Routing Service as an intermediary service which spawns the calls to multiple services. So in your scenario, your client would call the routing service and the routing service will in turn call each of your service
The following link should provide more information on routing service...
[Routing Service][1]
http://msdn.microsoft.com/en-us/library/ee517423.aspx
I'm relatively new into communication between applications, my goal is to have a Windows Service and somewhat a Managment Application where I can tell the service what to do, which methods to run (remote function calling). I stumbled upon "remoting", but a lot of people are telling this technique is deprecated and it's better to switch to something called WCF.
By this, I build my service according to this MSDN document:
http://msdn.microsoft.com/en-us/library/ms733069.aspx
I can install the service, run it, close it. But how do I interact with it? How does an "WCF client" application has to look like? It seems like WCF is something completely different to remoting, there are no server-client interfaces, no marshalled objects. I'm a litte bit confused, hope you can help.
You need have a Proxy/ChannelFactory for the client to interact with your WCF service.
On the client side you need a App.config/Web.config where you need to configure the endpoints the client has to lookfor for the service. You can do this programatically also.
Just go through the basics of WCF its easy than you think of it. :)
http://msdn.microsoft.com/en-us/library/ms731067.aspx
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
I'm about to start to develop and application in C# but I realized that I haven't the enough knowledge to develop it yet :S.
The thing's that I need to find out a way to let the Web server comunicate with my application, i.e., in short, is there a way to let the web server (not the Client which is the trivial case) send a messege to a Client application?
I know that I way to solve it's to make Client applications periodically send messages to the web server but that's not what I want 'cause polling generates overhead
Sorry about my english! I'm not a native speaker.
Thanks in advance!
Generally this type of interaction is achieved with Comet or WebSockets - I'm not sure how your app will be communicating with the server, but I would bet you can do what you're trying to do using one of those.
You could implement a WCF service in your client that could listen for a connection from the server (or anything else). The server can communicate with the client as easy as calling the API.
Getting started with WCF is really easy using the wizards in VS.
Here is a link that talks about using WCF with ASP, but it can be used outside of asp as well.
It seems like you meant "push" messaging, the challenge around this is for the server to keep track of the lost of clients and manage who should recieve which message.
If you want to get it done with minimal overhead you can check out the Amazon Simple Notification Service.
SNS is a cloud-based messaging and notification service hosted and managed for you, SNS is based on a topic/subscriber model and you set it up via a few simple API calls, it is metered but quite inexpensive for the most part.
edit: For C# Libraries and frameworks to do it yourself, I am not an expert in the C# world so I think other answerers will know it better.
Disclosure: I work at amazon so I am naturally inclined to like their product