Link to home
Start Free TrialLog in
Avatar of angelfire58
angelfire58

asked on

Uploading a file using Web Services

Hello,
I am trying to set up a Web Service such that the user can upload his files from his local drives (say C:) onto a remote location.

Let's say the web service is running on a box called WS2 and the files have to be stored on a box called DATA1. How do I create this web service such that the client uploads his local files using this Web Service on WS2 on the DATA1 box.

I've found a solution where one uses an ASP file to upload a file to a given location using ADODB stream, but I wouldn't to work with ASP.

Any suggestions?

Thanks
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

If this is on a web page, have you considered using the HTML input tag instead of a web service?

Alternately, if this is a client-side app, you could use FTP.
Avatar of Bob Learned
@Chaosian:

Jeff, are you talking about something like this:

Uploading Files with ASP.NET:
http://www.aspheute.com/english/20000802.asp

Bob
Avatar of angelfire58
angelfire58

ASKER

This is not through a web page.
The reason I am using this as a service is that we are centralizing our email systems. Multiple heterogenous programs are going to call this web service in order to send out emails. We also want to keep a track of all attachments sent and hence we want to store them on a separate box.

I've been looking around but haven't really found any other solutions.

Thanks again.
If you need to stick with the Web Service route, is there a reason that the web service can't run on the box where the data is being stored?  It sure would minimize the complexity.

Bob
Hello Bob,
Personally, reading the file from a remote location and sending it out through email is not a problem.
The problem is picking up this file from a local drive using a Web Service and then forwarding it to this location.

The method of using ADODB Binary Stream works fine, but it errors out on large attachment files. I've also been very curious about any other methods around and apparently there isn't much.

Thanks again.
Alex
Bob,
That looks about like what I was thinking. But it sounds like this is a client-side app... so I'd use one of the third-party .Net FTP clients to upload the file, then call a web service to send the actual e-mail. You could pass the sender, recipient, subject and body as variables to the web service, plus an array of file names for the attachment(s) that have already been transferred using FTP...
Jeff
I'm sure you could base64 encode any attachments and throw that in the XML file.
I've tried using base64 for XML and it works for small files but somehow errors out when I store large files on a remote location.

If however, I choose to store these large attachments locally on the same machine as that of the webservice, it works fine.

could it be a timeout issue?, how large of files are we talking about?  base64 encoding bloats the original filesize quite a bit
It could very well be a timeout issue. The file size I'm talking about ranges from 1MB-10MB. Usually anything thats around 1MB works fine and anything above that starts giving me errors.

I've even gone on to the web.config and changed the http runtime as follows:

<httpRuntime
            executionTimeout="90"
            maxRequestLength="11264"
            useFullyQualifiedRedirectUrl="false"
            minFreeThreads="8"
            minLocalRequestFreeThreads="4"
            appRequestQueueLimit="100"
      />

This doesn't solve the problem either.
How slow is the connection between these two computers?, I'd try to verify if this is really a timeout.  You may want to set it higher than 90 seconds.  You may also want to look into enforcing a max attachment size.  An ideal solution here would be to use a file transfer protocol, like FTP to get the files from one place to another, these protocols are meant to handle binary files, HTTP isn't...
I increased the timeout period to 300 seconds. It does not make a difference. The connection between these two computers is a t10 line so it should definitely not be a problem.

well if it is not a timeout issue, what is the issue?  Can you get more details on the error raised when it fails?
Hello,
I use an EasyMail component to send out an email. The component returns "error opening attachment file"

On the flip side, that would mean that it does not post the file on the network location. I've tried smaller files and then refreshed the location where it posts the files and it does put it there. On larger files, the file is never posted.

Today, I am going to try bringing the web service and the DATA box (i.e. box where these attachment files are stored) on the same box to check it that would work.

Ideally it should as it did work like that before, but the question would still remain unanswered:(

Thank you

I'd take the mailing part out for now, just get the files to the network computer first, then worry about emailing them.  If you say a file isn't getting there, certainly if you dig deep enough a reason can be found why.
I just checked the file transfer to the network computer and a local computer. Well now it's not transferring the files locally either. This local transfer still works from the other program. But my new project which copies files locally (with same code as that of the older one) does not work.

It gives me the following error message "Download of a specified resource has failed"

After doing some search on Google, I've noticed others have had this problem too, but could not find any specific solutions

Thanks
AspMaxRequestEntityAllowed is a setting in IIS6 that by default allows 200K I think. We changed this setting to 1GB just for test purposes. It seems to get rid of the error message "Download of a specific resource has failed" but does not transfer the file either. This is strange.

Any suggestions?
After a lot of research I finally solved the problem.
If you set the AspMaxRequestEntityAllowed to a value like 10MB (i.e. cap the size to the largest attachment you want to send) then it works fine.
IIS6 has the default set to a very low value and thus the XMLHTTP worked for small sized files.

IIS5 on the other hand did not have this setting and thus XMLHTTP works perfectly fine for any sized e-mails.

While MS claims that you don't have to restart IIS6 after changing this AspMaxRequestEntityAllowed attribute, I could not get it working unless I restarted IIS.

This solves my problem.

Thanks for all the support.

ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial