473,545 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Uploads to Web Service in both SOAP and HTTP-POST

I am trying to allow HTTP POST file uploads to my web service.
Currently I have it working perfectly for a SOAP/XML request reading
in a byte[ ] using MemoryStream/FileStream but I cannot figure out how
to encode a file on a POST to the same web service. The definition
requires a base64binary encoded file, which I have tried. The form is
also using a mutlipart/form-data enctype, but I either get a 500 error
or 'Request format is invalid'. Is there a trick to serializing a
form so that the web service will accept it as a byte[ ]?

Alternatively, I would be happy to differentiate the methods used and
create the files accordingly, ie. if its done over SOAP/XML use my
current method, or if its a POST call, use HttpFileCollect ion or
something? Can you differentiate how a web service was called within
the service itself?

Jul 6 '07 #1
6 5093
On Jul 5, 5:55 pm, Brybot <bryanr...@gmai l.comwrote:
I am trying to allow HTTP POST file uploads to my web service.
Currently I have it working perfectly for a SOAP/XML request reading
in a byte[ ] using MemoryStream/FileStream but I cannot figure out how
to encode a file on a POST to the same web service. The definition
requires a base64binary encoded file, which I have tried. The form is
also using a mutlipart/form-data enctype, but I either get a 500 error
or 'Request format is invalid'. Is there a trick to serializing a
form so that the web service will accept it as a byte[ ]?

Alternatively, I would be happy to differentiate the methods used and
create the files accordingly, ie. if its done over SOAP/XML use my
current method, or if its a POST call, use HttpFileCollect ion or
something? Can you differentiate how a web service was called within
the service itself?
Well it appears that if I convert to binary and separate each bit out
like &param=bit0&par am=bit1&param=b it2 etc... it will work...
unfortunately these files are +1Gb. Is there a better way to do this?

Jul 6 '07 #2
"Brybot" <br*******@gmai l.comwrote in message
news:11******** **************@ e9g2000prf.goog legroups.com...
On Jul 5, 5:55 pm, Brybot <bryanr...@gmai l.comwrote:
>I am trying to allow HTTP POST file uploads to my web service.
Currently I have it working perfectly for a SOAP/XML request reading
in a byte[ ] using MemoryStream/FileStream but I cannot figure out how
to encode a file on a POST to the same web service. The definition
requires a base64binary encoded file, which I have tried. The form is
also using a mutlipart/form-data enctype, but I either get a 500 error
or 'Request format is invalid'. Is there a trick to serializing a
form so that the web service will accept it as a byte[ ]?

Alternativel y, I would be happy to differentiate the methods used and
create the files accordingly, ie. if its done over SOAP/XML use my
current method, or if its a POST call, use HttpFileCollect ion or
something? Can you differentiate how a web service was called within
the service itself?

Well it appears that if I convert to binary and separate each bit out
like &param=bit0&par am=bit1&param=b it2 etc... it will work...
unfortunately these files are +1Gb. Is there a better way to do this?
XML Web Services are about XML. I don't think you're going to get files to
work the way you want to.

OTOH, WCF supports streaming data. See Large Data and Streaming
(http://msdn2.microsoft.com/en-us/library/ms733742.aspx), and How to: Enable
Streaming (http://msdn2.microsoft.com/en-us/library/ms789010.aspx).
--
John Saunders [MVP]

Jul 6 '07 #3
On Jul 5, 7:41 pm, "John Saunders [MVP]" <john.saunder s at
trizetto.comwro te:
"Brybot" <bryanr...@gmai l.comwrote in message

news:11******** **************@ e9g2000prf.goog legroups.com...
On Jul 5, 5:55 pm, Brybot <bryanr...@gmai l.comwrote:
I am trying to allow HTTP POST file uploads to my web service.
Currently I have it working perfectly for a SOAP/XML request reading
in a byte[ ] using MemoryStream/FileStream but I cannot figure out how
to encode a file on a POST to the same web service. The definition
requires a base64binary encoded file, which I have tried. The form is
also using a mutlipart/form-data enctype, but I either get a 500 error
or 'Request format is invalid'. Is there a trick to serializing a
form so that the web service will accept it as a byte[ ]?
Alternatively, I would be happy to differentiate the methods used and
create the files accordingly, ie. if its done over SOAP/XML use my
current method, or if its a POST call, use HttpFileCollect ion or
something? Can you differentiate how a web service was called within
the service itself?
Well it appears that if I convert to binary and separate each bit out
like &param=bit0&par am=bit1&param=b it2 etc... it will work...
unfortunately these files are +1Gb. Is there a better way to do this?

XML Web Services are about XML. I don't think you're going to get files to
work the way you want to.

OTOH, WCF supports streaming data. See Large Data and Streaming
(http://msdn2.microsoft.com/en-us/library/ms733742.aspx), and How to: Enable
Streaming (http://msdn2.microsoft.com/en-us/library/ms789010.aspx).
--
John Saunders [MVP]
Its not the files that are the problems, you can stream the files just
fine through XML, its the method of form POSTing a file to an XML
webservice, which again is possible without changing a thing, but you
have to marshal the file into binary and send it 1 bit to a post
variable. I was just wondering if there is an easier way to marshal a
file through a POST then bit by bit. Otherwise we just use a base64
binary stream which the SOAP envelope delivers as a byte [ ].

Jul 6 '07 #4
"Brybot" <br*******@gmai l.comwrote in message
news:11******** **************@ o11g2000prd.goo glegroups.com.. .
On Jul 5, 7:41 pm, "John Saunders [MVP]" <john.saunder s at
trizetto.comwro te:
>"Brybot" <bryanr...@gmai l.comwrote in message

news:11******* *************** @e9g2000prf.goo glegroups.com.. .
On Jul 5, 5:55 pm, Brybot <bryanr...@gmai l.comwrote:
I am trying to allow HTTP POST file uploads to my web service.
Currently I have it working perfectly for a SOAP/XML request reading
in a byte[ ] using MemoryStream/FileStream but I cannot figure out how
to encode a file on a POST to the same web service. The definition
requires a base64binary encoded file, which I have tried. The form is
also using a mutlipart/form-data enctype, but I either get a 500 error
or 'Request format is invalid'. Is there a trick to serializing a
form so that the web service will accept it as a byte[ ]?
>Alternativel y, I would be happy to differentiate the methods used and
create the files accordingly, ie. if its done over SOAP/XML use my
current method, or if its a POST call, use HttpFileCollect ion or
something? Can you differentiate how a web service was called within
the service itself?
Well it appears that if I convert to binary and separate each bit out
like &param=bit0&par am=bit1&param=b it2 etc... it will work...
unfortunately these files are +1Gb. Is there a better way to do this?

XML Web Services are about XML. I don't think you're going to get files
to
work the way you want to.

OTOH, WCF supports streaming data. See Large Data and Streaming
(http://msdn2.microsoft.com/en-us/library/ms733742.aspx), and How to:
Enable
Streaming (http://msdn2.microsoft.com/en-us/library/ms789010.aspx).
--
John Saunders [MVP]

Its not the files that are the problems, you can stream the files just
fine through XML, its the method of form POSTing a file to an XML
webservice, which again is possible without changing a thing, but you
have to marshal the file into binary and send it 1 bit to a post
variable. I was just wondering if there is an easier way to marshal a
file through a POST then bit by bit. Otherwise we just use a base64
binary stream which the SOAP envelope delivers as a byte [ ].
I've never seen this done with a web service. Do you mean that you POST to a
..ASMX file? Could you post a simple example?
--
John Saunders [MVP]

Jul 7 '07 #5
On Jul 6, 5:49 pm, "John Saunders [MVP]" <john.saunder s at
trizetto.comwro te:
"Brybot" <bryanr...@gmai l.comwrote in message

news:11******** **************@ o11g2000prd.goo glegroups.com.. .
On Jul 5, 7:41 pm, "John Saunders [MVP]" <john.saunder s at
trizetto.comwro te:
"Brybot" <bryanr...@gmai l.comwrote in message
>news:11******* *************** @e9g2000prf.goo glegroups.com.. .
On Jul 5, 5:55 pm, Brybot <bryanr...@gmai l.comwrote:
I am trying to allow HTTP POST file uploads to my web service.
Currently I have it working perfectly for a SOAP/XML request reading
in a byte[ ] using MemoryStream/FileStream but I cannot figure out how
to encode a file on a POST to the same web service. The definition
requires a base64binary encoded file, which I have tried. The form is
also using a mutlipart/form-data enctype, but I either get a 500 error
or 'Request format is invalid'. Is there a trick to serializing a
form so that the web service will accept it as a byte[ ]?
Alternatively, I would be happy to differentiate the methods used and
create the files accordingly, ie. if its done over SOAP/XML use my
current method, or if its a POST call, use HttpFileCollect ion or
something? Can you differentiate how a web service was called within
the service itself?
Well it appears that if I convert to binary and separate each bit out
like &param=bit0&par am=bit1&param=b it2 etc... it will work...
unfortunately these files are +1Gb. Is there a better way to do this?
XML Web Services are about XML. I don't think you're going to get files
to
work the way you want to.
OTOH, WCF supports streaming data. See Large Data and Streaming
(http://msdn2.microsoft.com/en-us/library/ms733742.aspx), and How to:
Enable
Streaming (http://msdn2.microsoft.com/en-us/library/ms789010.aspx).
--
John Saunders [MVP]
Its not the files that are the problems, you can stream the files just
fine through XML, its the method of form POSTing a file to an XML
webservice, which again is possible without changing a thing, but you
have to marshal the file into binary and send it 1 bit to a post
variable. I was just wondering if there is an easier way to marshal a
file through a POST then bit by bit. Otherwise we just use a base64
binary stream which the SOAP envelope delivers as a byte [ ].

I've never seen this done with a web service. Do you mean that you POST to a
.ASMX file? Could you post a simple example?
--
John Saunders [MVP]
For sure, if you enable HTTP-POST in your web.config (or
machine.config) , your asmx descriptions include POST examples as
well. It'll demonstrate with GET because its easier to see and
essentially the same thing:

http://webservice/MethodName?var1=x&var2=y

that works fine and takes two variables, but for sending files (var3)
via POST or GET you need to do something like this:

http://webservice/MethodName?var1=x&...r3=1...&var3=1

you need to send each bit of the file in its own container (var3).
The webservice sees this as your bit [ ] and the file is demarshalled
correctly, but the POST/GET headers become incredibly big.

I've gotten the clients to move onto using SOAP, but I was wondering
for professional curiosity if there was a better way of doing it. If
you're using POST you can always look to httpcontext for uploaded
files, but thats not really using the webservice properly or securely,
probably the only viable solution though.
Jul 9 '07 #6
"Brybot" <br*******@gmai l.comwrote in message
news:11******** **************@ z28g2000prd.goo glegroups.com.. .
On Jul 6, 5:49 pm, "John Saunders [MVP]" <john.saunder s at
trizetto.comwro te:
>"Brybot" <bryanr...@gmai l.comwrote in message

news:11******* *************** @o11g2000prd.go oglegroups.com. ..
On Jul 5, 7:41 pm, "John Saunders [MVP]" <john.saunder s at
trizetto.comwro te:
"Brybot" <bryanr...@gmai l.comwrote in message
>>news:11****** *************** *@e9g2000prf.go oglegroups.com. ..
On Jul 5, 5:55 pm, Brybot <bryanr...@gmai l.comwrote:
I am trying to allow HTTP POST file uploads to my web service.
Currently I have it working perfectly for a SOAP/XML request
reading
in a byte[ ] using MemoryStream/FileStream but I cannot figure out
how
to encode a file on a POST to the same web service. The definition
requires a base64binary encoded file, which I have tried. The form
is
also using a mutlipart/form-data enctype, but I either get a 500
error
or 'Request format is invalid'. Is there a trick to serializing a
form so that the web service will accept it as a byte[ ]?
>Alternativel y, I would be happy to differentiate the methods used
and
create the files accordingly, ie. if its done over SOAP/XML use my
current method, or if its a POST call, use HttpFileCollect ion or
something? Can you differentiate how a web service was called
within
the service itself?
Well it appears that if I convert to binary and separate each bit
out
like &param=bit0&par am=bit1&param=b it2 etc... it will work...
unfortunately these files are +1Gb. Is there a better way to do
this?
>XML Web Services are about XML. I don't think you're going to get
files
to
work the way you want to.
>OTOH, WCF supports streaming data. See Large Data and Streaming
(http://msdn2.microsoft.com/en-us/library/ms733742.aspx), and How to:
Enable
Streaming (http://msdn2.microsoft.com/en-us/library/ms789010.aspx).
--
John Saunders [MVP]
Its not the files that are the problems, you can stream the files just
fine through XML, its the method of form POSTing a file to an XML
webservice, which again is possible without changing a thing, but you
have to marshal the file into binary and send it 1 bit to a post
variable. I was just wondering if there is an easier way to marshal a
file through a POST then bit by bit. Otherwise we just use a base64
binary stream which the SOAP envelope delivers as a byte [ ].

I've never seen this done with a web service. Do you mean that you POST
to a
.ASMX file? Could you post a simple example?
--
John Saunders [MVP]

For sure, if you enable HTTP-POST in your web.config (or
machine.config) , your asmx descriptions include POST examples as
well. It'll demonstrate with GET because its easier to see and
essentially the same thing:

http://webservice/MethodName?var1=x&var2=y

that works fine and takes two variables, but for sending files (var3)
via POST or GET you need to do something like this:

http://webservice/MethodName?var1=x&...r3=1...&var3=1

you need to send each bit of the file in its own container (var3).
The webservice sees this as your bit [ ] and the file is demarshalled
correctly, but the POST/GET headers become incredibly big.

I've gotten the clients to move onto using SOAP, but I was wondering
for professional curiosity if there was a better way of doing it. If
you're using POST you can always look to httpcontext for uploaded
files, but thats not really using the webservice properly or securely,
probably the only viable solution though.
Would this work for you? If not, I'm curious to know why not:
OTOH, WCF supports streaming data. See Large Data and Streaming
(http://msdn2.microsoft.com/en-us/library/ms733742.aspx), and How to:
Enable
Streaming (http://msdn2.microsoft.com/en-us/library/ms789010.aspx).
--
John Saunders [MVP]

Jul 9 '07 #7

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

Similar topics

2
4710
by: Johnny | last post by:
Searched on google for any info relating to this before posting here but found none. I set up a web service using nusoap on apache php 4.3.8 on windows with error_reporting = E_ALL and had that service set a cookie in the client browser as the first output. Works fine in IE6 and the service returns the state of the cookie in the client...
0
1935
by: Dave | last post by:
Hi, If anyone could help with this, I would greatly appreciate it! I've created my own WSDL file and referenced an XSD file too. I've generated a service side interface using wsdl /server, and created an ASMX file from this. I've then set the Binding for the class and methods and set the Location to my WSDL file. If I put the wsdl:service...
1
2289
by: moonriver | last post by:
In a xml file, can we make reference to another xml file so that all contents of the latter xml file will be included into the first xml file? Had better give me an example for details.
1
3935
by: Eirik Brattbakk | last post by:
Hi I have some problems accessing a soap service made in c# using an ATL/MFC client over SSL. I have tried both CSoapMSXMLInetClient and CSoapWininetClient as template arguments with my stub class. The service is returning with the error code: -2147467259. I have not succeeded to find any additional information about the error. The...
2
2066
by: Reshma Prabhu | last post by:
Hello, I have created an web service in C# and accessing it thrugh C++ code. But when i make a call through the client, the parameter does not reach the server but it does not show any error code on client. I have attached my code with this Connector.CreateInstance(__uuidof(HttpConnector30)); Connector->Property =
2
4208
by: Burak | last post by:
Hello, I have a web service that has a two user defined public classes. For sake of brevity, I'll write them as follows Public Class Service1 Public Class Class1 Public x as integer End Class
4
6188
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and pass the data to the web service. I already modified both web.config files and changed maxRequestLength to 60000(kb). When I debug the upload process,...
3
6475
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service07162002.asp) but I don't want clients to have to add two web references and then manually have to edit the proxy classes....
0
1321
by: dpp | last post by:
Hi I am calling a method of a .NET component from both win forms and web service applications. Strangly, it is working fine from win forms application, but when i call the same method (same code with same input values) of that . NET component from the web service method it is giving the following exception,
2
5119
by: pmlane2001 | last post by:
I have a PHP SOAP XML file size problem that I was wondering if anyone has seen before. I have an XML file that when I put it through my PHP script with 270 lines (13,082 KB) it works fine. If I make it 271 lines (13,112 KB), it causes the script to end with a soap fault. I've tried adding substance to the 270 lines to make the file bigger...
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7433
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1020
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
712
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.