Or...if you need to do some kind of processing and return a value (like
most web services do) then create a web page and do something like
below. I was working on this today before the project was cancelled and
got it to work.
It receives 513 bytes at a time and writes them to a file. The bytes
are supposed to be an XML file with one node containing base64 text of
another file. It extracts that out and saves that to a file for
processing. It then reads a file and sends those bytes back to the
caller at 513 bytes at a time.
This is just a test case to prove it would work so bugs may exist but it
did work with the files I was using.
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Try
Dim bytecount As Int32
Dim bytecount2 As Int32
Dim Position As Int32
Dim NumOfBytes As Int32 = 512
Dim ReadBs As Int32
bytecount = Request.TotalBytes
bytecount2 = bytecount
Dim b() As Byte = Nothing
Dim F As System.IO.FileStream
If bytecount2 > 0 Then
F = New
System.IO.FileStream("c:\PGPworkingDir\test.dat", IO.FileMode.Create)
Do Until bytecount = 0
ReDim b(NumOfBytes - 1)
If Request.InputStream.Length < NumOfBytes Then
NumOfBytes = CType(Request.InputStream.Length,
Int32)
End If
b = Request.BinaryRead(NumOfBytes)
Position += NumOfBytes
F.Write(b, 0, b.Length)
F.Flush()
bytecount -= NumOfBytes
If bytecount < NumOfBytes And bytecount > 0 Then
NumOfBytes = bytecount
End If
Loop
F.Close()
F = New
System.IO.FileStream("c:\PGPworkingDir\test.dat", IO.FileMode.Open)
Dim xml As New System.Xml.XmlTextReader(F)
Dim OutFile As New
System.IO.FileStream("c:\PGPworkingDir\FiletToEncrypt.dat",
IO.FileMode.Create)
xml.ReadToFollowing("file-contents")
NumOfBytes = 512
ReDim b(NumOfBytes)
Do
ReadBs = xml.ReadElementContentAsBase64(b, 0,
NumOfBytes)
'ReadBs = xml.ReadValueChunk(Cs, 0, NumOfBytes)
If ReadBs < 512 Then
ReDim Preserve b(ReadBs - 1)
OutFile.Write(b, 0, ReadBs)
Exit Do
End If
OutFile.Write(b, 0, ReadBs)
Loop
OutFile.Flush()
OutFile.Close()
xml.Close()
F.Close()
End If
F = New
System.IO.FileStream("c:\PGPworkingDir\decrypt_pdf_response.xml",
IO.FileMode.Open)
Position = 0
NumOfBytes = 512
ReDim b(NumOfBytes - 1)
Do
ReadBs = F.Read(b, 0, NumOfBytes)
If ReadBs < 512 Then
ReDim Preserve b(ReadBs - 1)
Response.BinaryWrite(b)
Exit Do
End If
Response.BinaryWrite(b)
Loop
Response.Flush()
Response.Close()
F.Close()
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub
End Class
-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Stoyan Damov
Sent: Monday, August 20, 2007 3:15 PM
To: [email protected]
Subject: Re: [ADVANCED-DOTNET] WCF and MTOM
On 8/20/07, Nicolas Roy <[EMAIL PROTECTED]> wrote:
> I'm using HTTP binding and MTOM encoding to transfer large document
over a
...
> Anyone has experimented MTOM ?
>
I did and my answer is this - I want to spare you a *LOT* of
suffering, so for file transfer over the web:
- don't use WCF
- don't use MTOM
- don't use web services
- use plain and simple HTTP file upload
If anyone disagrees with me and/or wants to suggest anything -
*please* share it with Nicolas and not with *me*.
Cheers,
Stoyan
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com