473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Returning a file from Web Service

I have written a Web Service that interacts with a COM component to extract
a file from another system. Basically the Web Service accepts a part number
and a rev and extracts the file to a subfolder of the Web Service. What is
the best way to get this file to the client?

The client is a web application that's being written in C#. What I'd like
to be able to do is to return the file in the same manner as it would be if
a hyperlink to the file were clicked on (With the usual "File Download - Do
you want to open or save this file?" dialog). Sorry, but that's the best I
can do to describe the effect I want, hopefully everyone understands what I
mean.

I know that I can return it as a byte array which can be re-assembled on the
client side, but I'm not the one developing the client app and I don't know
what flexibility they have there. It would be nice if they could call the
Web Service from say, a button click, and just have the file open. By the
way, in case it matters, these will all be pdf files.

Any help would be appreciated.
Alan Sloan
Apr 17 '07 #1
1 3855
Sorry, but the intent of a web service is to return a value (or values) to
the caller, just as a regular function would, but over HTTP/HTTPS. Any way
I've seen this done, the client will have to reassemble the byte array (or
BASE64 string, etc), save the file off into some temp dire, and send the file
using the HttpResponse object. HOWEVER, there may be a way for you to have
them send you a Response object, and you can then try setting up the
OutputStream property with your file, but I'm not sure if that will work
(never tried it).

If that doesn't work, you could offer a separate asp page they can pass
query strings to (or post form contents to) that calls the web service,
assembles the file, and then sends the stream in the response, which will
open up your "open or save this file" dialog.

-Keith

"Alan Sloan" wrote:
I have written a Web Service that interacts with a COM component to extract
a file from another system. Basically the Web Service accepts a part number
and a rev and extracts the file to a subfolder of the Web Service. What is
the best way to get this file to the client?

The client is a web application that's being written in C#. What I'd like
to be able to do is to return the file in the same manner as it would be if
a hyperlink to the file were clicked on (With the usual "File Download - Do
you want to open or save this file?" dialog). Sorry, but that's the best I
can do to describe the effect I want, hopefully everyone understands what I
mean.

I know that I can return it as a byte array which can be re-assembled on the
client side, but I'm not the one developing the client app and I don't know
what flexibility they have there. It would be nice if they could call the
Web Service from say, a button click, and just have the file open. By the
way, in case it matters, these will all be pdf files.

Any help would be appreciated.
Alan Sloan
Apr 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Randy | last post by:
Hello, I have a web service in which I'm doing a query to an Access database and returning the resulting XML data when I do the return from the service... public string AOS_Data(string sql) {...
5
by: LS | last post by:
Can a WebMethod return an Interface type? Can we pass an interface parameter ? Example : public interface IEntity { long Id { get; set; } string Name { get; set; } }
1
by: Matthias De Ridder | last post by:
Hello, I really hope that someone will be able to help me, because I'm desperate now! I'm a student, graduating this year, and I'm working on a thesis where C# Web Services are involved. I...
3
by: James | last post by:
I need to create a C# web service that returns a recordset for an ASP classic applicaiton to consume. My problem is that so far the only thing that I have found I can return is a dataset using...
5
by: Jim Murphy | last post by:
In creating a C# web service, I am having trouble returning a DataTable object as the result of a web method. I have no problem returning native types like string or int, but cannot return a .NET...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
13
by: cj | last post by:
I wrote this code in a windows app and it works: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ds As New DataSet Dim...
5
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
1
by: Mike | last post by:
Hi, I have a WCF service that works perfectly. I added a new function (returning typed Dataset) and now, my service doesn't work anymore. I got a lot of "CODEGEN" warning inside the proxy file...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.