using web service to get a file - c#

I have a zip file and I have client application I need to send my files to web service how I can implement it easily ?
web service should have ability to store them on the server.

You can either do it the easy way just by passing an array of bytes to your web service like this or you can use a more complex way and send it as a FileStream (I have never tried the second way) like this.

Related

Write Json to server endpoint

I have an Ubuntu server instance running in Amazon EC2.
I want to write json to an endpoint in that url, for instance "http://myurl/myendpoint".
How do I create this endpoint and how do I write json to it with C#?
Information you gave are too scarse. What exactly are you tryingt to achieve? Do you have a REST API deployed on that server? If not, then you probably want to create a REST Api. You can use it to create a mechanism that will be able to handle requests/responses.
https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api

How can I create a WCF service that allows users to connect to my service through a web browser and upload a file?

I've created a Hello World WCF service that uses the ASP.NET Development Server - I launch the client which opens a page in my web browser, HelloWorldService.svc, then this triggers the command prompt to open and print out a Hello World message.
I don't fully understand this chain of action or how it's useful.
I'm trying to create a WCF service that acts as a server that allows users to connect to the server and perform a file upload - I will take this file and store it locally on my machine.
For now, allowing this to work locally on only my PC is fine but I really don't know where to begin to accomplish this. Any advice would be appreciated.
EDIT: I NEED to use WCF. So please don't suggest alternative solutions.
WCF is arguably overkill. Simplest case, just use the standrad .Net FileUpload control.
Here are some examples:
ASP.NET File Upload
http://asp.net-tutorials.com/controls/file-upload-control/
Which leads to the question "When should I use WCF"? Here are a couple of answers:
When & where I should use WCF
http://forums.asp.net/t/1480028.aspx
http://msdn.microsoft.com/en-us/library/cc512038.aspx
http://forums.asp.net/t/1478962.aspx
Finally, here are a couple of links that describe WCF-based file transfer services:
http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP
http://code.msdn.microsoft.com/windowsdesktop/Upload-files-using-a-REST-13f16af2

Best way to get copy of remote XML?

I need access to a couple of XML files on a remote server. Because of the crossdoamin policies, i cannot do it with jQuery alone, but need a small c# .aspx page, which will act as a gateway for my jQuery to fetch the remote xml from a local file. But how would i best go about this page - what is the simplest structure of such a file?
You could use a "Generic Handler" (ASHX file).
I'll use these kind of files often when sending files to the browser, without the need for an UI (i.e. no visible page content).
In my understanding I see ASHX handlers as "pages without an UI" that have low overhead compared to a normal Page.
Why not a web service?
client code (jQuery) -> your server (WCF) -> external xml
You can quickly create a REST web service with this template.

Approach for file Uploads to service from Web Server

I have to create service that can get files from any authorized source and save them on file server. Then return back response with url for that resource.
The issue is that the service could be accessible from any web site or app. In case of Web site, what would be the best way to get file from a user and stream it to the service? Or do i have to save it to the web server first and then replay the stream to the service? I am thinking of creating Httphandler to channel traffic from web server (the instant file upload request is initiated by user) to the service. Would that be the best approach, or what would?
I have just implemented file transfer service for our internal use. It was a trivial service to implement that with WCF RESTFul way. What you need to do is to implement streaming over Http.
Actually, I have chosen new WCF Web Api to achieve this feature.
But if you are familiar with that, here you can see a good example on how you can implement this :
http://blogs.msdn.com/b/gblock/archive/2010/11/24/streaming-over-http-with-wcf.aspx

WCF web service - how can I view XML request and response inside my app?

I am writing a C# WinForms application that consumes a web service using WCF. I would like to be able to display the XML request and response in the application in real-time as the calls are happening. Is this possible?
You would probably want to use / write a custom MessageInspector:
http://msdn.microsoft.com/en-us/library/aa717047%28v=VS.90%29.aspx
Another handy way to look at the raw communication is to enable tracing (but this would log the messages outside your application which might not suit your needs):
http://msdn.microsoft.com/en-us/library/ms733025.aspx

Categories

Resources