I am trying to create a client-server application that would communicate
using xml in a http format.
I already researched about client-server transferring file using TCP/IP.
It uses tcclient/tcplistener which worked very fine. However I was trying to
build an application that could use an http format of request to do the transferring of file.
I also had downloaded some codes for an implementation of an http server
but the http client needs to be a web browser, is there a way that I could just have a c# windows FORM as a client and pass those http webrequest/webresponse classes ?
Is there any suggestion that you can give?
Thank you very much in advance.
I hope you could help.
I think what you're doing here is basically reinventing Web Services. For .NET, you can either look at ASMX Web Services or at WCF.
I also think should have a look at Windows Communication Foundation, it gives a lot of possibilities, settings and security. I recommend the following books to read, that also helped me:
Professional WCF 4: Windows Communication Foundation with .NET 4
(Wrox Programmer to Programmer)
Programming WCF Services, Third Edition
Hope it helps you.
Related
Some time ago, I designed an application to an exisitng system. The application allows updating some app in PDA's. It is a kind of a remote updater. It uses web service.
Before I designed the application I had read some articles about WCF - technology. Then, I found a piece of information about comparision between SOAP protocol and REST architecture. Then I understood that REST is more useful for devices such as mobile or PDA's. Because of REST requires less data than SOAP. Obviously, I read more about REST that it uses HTTP methods and I know a lot about it.
As a result, I decided to use the REST architecture and everything was good. The application is still using.
Recently, I have changed my job. There is an application which uses a web service to sending data to PDA's. The web service uses SOAP protocol. I was very surprised when I have seen it first time. In my job, nobody can't tell me about it with some reasons.
Summarizing my story, I need to know that I am right that REST is a better option for a web service when we need to connect with PDA's or both option are correct. I don't need some description between SOAP vs. REST. I would like to receive a precision answer.
I have C# apps requesting data from PHP/MySQL API server (Rest/JSON). Now I also need to push messages to the C# apps when some events occur (form submission from the web site). I searched around, and it seems that COMET, long polling, and http streaming are options. Could you please provide some suggestions on which technology makes sense here, as I am not pushing to a web browser?
In addition, if using HTTP streaming (like twitter streaming API), do I need to keep a table of HTTP connections so I know which connection to use when pushing targeted events (only to certain C# clients)? I am a bit confused, and many thanks!
Make a WCF Web Service. http://www.codeproject.com/KB/WCF/WCFWebService.aspx
To connect using PHP: http://weblogs.asp.net/gunnarpeipman/archive/2007/09/17/using-wcf-services-with-php.aspx
In micro-services environment you might want to communicate between more different coding languages in the future, that's why in Kaltura we expose every API with descriptive XML that we can use later to generate client libraries in multiple coding languages, our code generator includes client libraries for C# and PHP.
I also published several REST server examples, including C#.
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
So,
I found that amazing thing called HTML5 WebSockets, new API. That is still in DRAFT version, but quite well supported. Full-duplex bi-directional communication. I know how to use it via JavaScript, there is APIs. But if I want to use a WebSocket client within my C#/.NET application, how to do that?
For example JavaScript: http://bohuco.net/blog/2010/07/html5-websockets-example/
Are there are any special client libraries for WebSockets in .NET?
sir
SuperWebSocket include a WebSocket server implementation and a WebSocket client implementation.
SuperWebSocket's project page
I've recently done some research into this whilst building a .NET and Silverlight client library for Pusher. I found the following WebSocket client libraries and projects:
Microsoft WebSocket client prototype
SuperWebSocket note: there is a client in there, it's just difficult to find
WebSocket-Sharp
Anaida
For the moment the Microsoft implementation is probably the easiest to use and it also has a Silverlight library. SuperWebSockets has a Silverlight project in the source but not in the latest drop.
Starting from .NET 4.5, WebSocket clients are supported via System.Net.WebSockets.ClientWebSocket
You can browse or download this sample C# app from MSDN Code website: http://code.msdn.microsoft.com/WebSockets-middle-tier-5b2972ce/sourcecode.
To the down-voters of the question, the sample is mainly focused on connecting to WebSocket services, which is another significant use-case for a network-centric C# application.
I havenĀ“t tried the Microsoft implementation, but I think Xsockets has the fastest setup time (nuget package). Under 3 min from start to running a complete socketserver + client (demo chat application). Youtube demo
It has fallback to Silverlight and flash for older browsers.
You could use http://www.nuget.org/packages/Microsoft.AspNet.SignalR/ or http://www.asp.net/signalr
ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and side. Servers can now push content to connected cliently instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization.
A friend an I just released a very lightweight, lean, scalable C# websocket server: https://github.com/Olivine-Labs/Alchemy-Websockets
We built it to use in our online game, so our top concern was the quick and efficient handling of tons of connections. It's, from my research, the most efficient out there. And, as a bonus, it supports flash websockets as a fallback for users without websocket-enabled browsers.
If you're looking for a high performance enterprise WebSocket server, take a look at Kaazing. Kaazing has complete support for .NET including Xamarin.
Here is a step-by-step tutorial for AMQP: Checklist: Build Microsoft .NET AMQP Clients.
[Disclosure: I work for Kaazing.]
Yes, you will need an intermediary server which supports the WebSocket protocol. This server could be written in any language including .NET. Here's one for .NET but it really could be any language. As far as your site is concerned it could be ASP.NET and the client part in javascript which will talk to the WebSocket server.
I'm deploying XSockets.net. The framework works quite good, it is being maintained, the developers offer paid support but for normal issues they are also quite active here in SO and they help a lot.
They offer a .net API for implementing the sockets and also a javascript API for the client.
As a summary, I can recommend it.
You have a few choices
Roll your own - the spec is fairly simple
Use someone else's experimental version, such as this one C# Web socket server
Look into the MS WCF approach
I have a server client application.
The clients sends the server http posts with info every second or so.
The server is implemented using C#, there server doesn't need to respond in any way to the client.
Whats the easiest and most practical way to get this done? Is there some kind of library that is easy to use that I can import into my project.
Why not just use a regular old web service? It sounds like you have simple functionality that doesn't need to maintain a connection state. With a web service, you can simply expose the methods to your client, accessible via HTTP/S. If you're already using .NET for your client, you can simply add a web reference to your project and have .NET do the heavy lifting for you. There wouldn't be any need to reinvent the wheel.
You can use http.sys to create your own http listener without IIS or additional overhead. Aaron Skonnard has a good article here.
Because of certain limitations of uhttpsharp (specifically no support for POST forms and file uploads and it using threads to process requests), I've made NHttp available at github which supports full request parsing like ASP.net and processes requests using the asynchronous TCP model.