Connecting Tech Pros Worldwide Forums | Help | Site Map

Stream large file in WSE 3.0

Hardy Wang
Guest
 
Posts: n/a
#1: Oct 3 '06
Hi all,
I am new to WSE 3.0, and currently reading the document shipped with
installation. From sample provided (see below), I created WSE service side
code, but how can I consume stream returned by web method in my Web Form
application? I already configurated web.config of my web service by running
WSE 3.0 setting tool.

Thanks!


[WebMethod(BufferResponse = false)]
public GetFileResponseWrapper GetStream () {
String filePath = @"e:\temp\70ONEEL06COMP.pdf";
return new GetFileResponseWrapper(filePath);
}


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.CodeDom.Compiler;

/// <summary>
/// Summary description for GetFileResponseWrapper
/// </summary>
[XmlSchemaProvider("GetMySchema")]
public class GetFileResponseWrapper : IXmlSerializable, IDisposable {
private string _fileName;
private TempFileCollection tfc = null;

public string FileName { get { return _fileName; } }

public GetFileResponseWrapper ()
: this(null) {
}

public GetFileResponseWrapper (string fileName) {
_fileName = fileName;
// Manages the temp file that contains the file contents
// Dispose this wrapper to clean up temp files.
TempFileCollection tfc = new TempFileCollection();
}

#region Dispose logic
~GetFileResponseWrapper () {
Dispose(false);
}

public void Dispose () {
Dispose(true);
}

void Dispose (bool isDisposing) {
if (isDisposing && tfc != null)
tfc.Delete();
tfc = null;
}
#endregion

/// <summary>
/// The schema for the file contents node is actually just
/// base 64 binary data so return the qname of the schema
/// type directly.
/// </summary>
public static XmlQualifiedName GetMySchema (XmlSchemaSet xss) {
return new XmlQualifiedName("Base64Binary",
"http://www.w3.org/2001/XMLSchema");
}

/// <summary>
/// Always return null.
/// </summary>
public XmlSchema GetSchema () { return null; }

/// <summary>
/// Deserializes state out of an XmlReader
/// </summary>
public void ReadXml (XmlReader r) {
// Read the open tag of the encapsulating element
r.ReadStartElement();

//
// Read the binary data that represents the file contents
// into a temp file.
//
_fileName = tfc.AddExtension("fileContents", false);
ReadContentsIntoFile(r, _fileName);

// Read the close tag of the encapsulating element
r.ReadEndElement();
}

/// <summary>
/// Serializes state into an XmlWriter
/// </summary>
public void WriteXml (XmlWriter w) {
using (FileStream fs = new FileStream(_fileName, FileMode.Open)) {
byte[] buf = new byte[1024];
int numRead = 0;
while ((numRead = fs.Read(buf, 0, 1024)) 0) {
w.WriteBase64(buf, 0, numRead);
}
}
}

void ReadContentsIntoFile (XmlReader r, string fileName) {
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
if (r.CanReadBinaryContent) {
byte[] buf = new byte[1024];
int numRead = 0;
while ((numRead = r.ReadContentAsBase64(buf, 0, 1024)) 0)
{
fs.Write(buf, 0, numRead);
}
} else {
throw new NotSupportedException();
}
}
}
}


Champika Nirosh
Guest
 
Posts: n/a
#2: Oct 3 '06

re: Stream large file in WSE 3.0


Hi,

To my knowledge if you are to utilize the WSE MTOM then you got to send your
file as a byte[] not as a custom object at your will.. only the byte[] will
recognize by the Optimization machanism..

The GetFileResponseWrapper will pass olny the single public property it
has.. that is... FileName but in your case that also will not since it does
not have the setter part, since the object serialization/ deserialization is
needed the set/ get both to send it via SOAP successfully... I think you are
doing this very veyr wrong..

Since you said you are reading the help I will stop it here...

Nirosh.

object
"Hardy Wang" <hardywang@hotmail.comwrote in message
news:Oqxq2uo5GHA.3960@TK2MSFTNGP02.phx.gbl...
Quote:
Hi all,
I am new to WSE 3.0, and currently reading the document shipped with
installation. From sample provided (see below), I created WSE service side
code, but how can I consume stream returned by web method in my Web Form
application? I already configurated web.config of my web service by
running WSE 3.0 setting tool.
>
Thanks!
>
>
[WebMethod(BufferResponse = false)]
public GetFileResponseWrapper GetStream () {
String filePath = @"e:\temp\70ONEEL06COMP.pdf";
return new GetFileResponseWrapper(filePath);
}
>
>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.CodeDom.Compiler;
>
/// <summary>
/// Summary description for GetFileResponseWrapper
/// </summary>
[XmlSchemaProvider("GetMySchema")]
public class GetFileResponseWrapper : IXmlSerializable, IDisposable {
private string _fileName;
private TempFileCollection tfc = null;
>
public string FileName { get { return _fileName; } }
>
public GetFileResponseWrapper ()
: this(null) {
}
>
public GetFileResponseWrapper (string fileName) {
_fileName = fileName;
// Manages the temp file that contains the file contents
// Dispose this wrapper to clean up temp files.
TempFileCollection tfc = new TempFileCollection();
}
>
#region Dispose logic
~GetFileResponseWrapper () {
Dispose(false);
}
>
public void Dispose () {
Dispose(true);
}
>
void Dispose (bool isDisposing) {
if (isDisposing && tfc != null)
tfc.Delete();
tfc = null;
}
#endregion
>
/// <summary>
/// The schema for the file contents node is actually just
/// base 64 binary data so return the qname of the schema
/// type directly.
/// </summary>
public static XmlQualifiedName GetMySchema (XmlSchemaSet xss) {
return new XmlQualifiedName("Base64Binary",
"http://www.w3.org/2001/XMLSchema");
}
>
/// <summary>
/// Always return null.
/// </summary>
public XmlSchema GetSchema () { return null; }
>
/// <summary>
/// Deserializes state out of an XmlReader
/// </summary>
public void ReadXml (XmlReader r) {
// Read the open tag of the encapsulating element
r.ReadStartElement();
>
//
// Read the binary data that represents the file contents
// into a temp file.
//
_fileName = tfc.AddExtension("fileContents", false);
ReadContentsIntoFile(r, _fileName);
>
// Read the close tag of the encapsulating element
r.ReadEndElement();
}
>
/// <summary>
/// Serializes state into an XmlWriter
/// </summary>
public void WriteXml (XmlWriter w) {
using (FileStream fs = new FileStream(_fileName, FileMode.Open)) {
byte[] buf = new byte[1024];
int numRead = 0;
while ((numRead = fs.Read(buf, 0, 1024)) 0) {
w.WriteBase64(buf, 0, numRead);
}
}
}
>
void ReadContentsIntoFile (XmlReader r, string fileName) {
using (FileStream fs = new FileStream(fileName,
FileMode.CreateNew)) {
if (r.CanReadBinaryContent) {
byte[] buf = new byte[1024];
int numRead = 0;
while ((numRead = r.ReadContentAsBase64(buf, 0, 1024)) 0)
{
fs.Write(buf, 0, numRead);
}
} else {
throw new NotSupportedException();
}
}
}
}
>

Hardy Wang
Guest
 
Posts: n/a
#3: Oct 3 '06

re: Stream large file in WSE 3.0


Thanks for your comment, I read this example from
ms-help://MS.WSE30.1033/WSE3.0/html/3e9ce678-2502-4847-9f13-5173896c9db5.htm
or from MS MSDN
http://msdn.microsoft.com/library/de...73896c9db5.asp

Any idea what should I do?

"Champika Nirosh" <test@tc.comwrote in message
news:OpQFQvs5GHA.4608@TK2MSFTNGP03.phx.gbl...
Quote:
Hi,
>
To my knowledge if you are to utilize the WSE MTOM then you got to send
your file as a byte[] not as a custom object at your will.. only the
byte[] will recognize by the Optimization machanism..
>
The GetFileResponseWrapper will pass olny the single public property it
has.. that is... FileName but in your case that also will not since it
does not have the setter part, since the object serialization/
deserialization is needed the set/ get both to send it via SOAP
successfully... I think you are doing this very veyr wrong..
>
Since you said you are reading the help I will stop it here...
>
Nirosh.
>
object
"Hardy Wang" <hardywang@hotmail.comwrote in message
news:Oqxq2uo5GHA.3960@TK2MSFTNGP02.phx.gbl...
Quote:
>Hi all,
> I am new to WSE 3.0, and currently reading the document shipped with
>installation. From sample provided (see below), I created WSE service
>side code, but how can I consume stream returned by web method in my Web
>Form application? I already configurated web.config of my web service by
>running WSE 3.0 setting tool.
>>
>Thanks!
>>
>>
>[WebMethod(BufferResponse = false)]
>public GetFileResponseWrapper GetStream () {
> String filePath = @"e:\temp\70ONEEL06COMP.pdf";
> return new GetFileResponseWrapper(filePath);
>}
>>
>>
>using System;
>using System.Data;
>using System.Configuration;
>using System.Web;
>using System.Web.Security;
>using System.Web.UI;
>using System.Web.UI.WebControls;
>using System.Web.UI.WebControls.WebParts;
>using System.Web.UI.HtmlControls;
>using System.IO;
>using System.Xml;
>using System.Xml.Serialization;
>using System.Xml.Schema;
>using System.CodeDom.Compiler;
>>
>/// <summary>
>/// Summary description for GetFileResponseWrapper
>/// </summary>
>[XmlSchemaProvider("GetMySchema")]
>public class GetFileResponseWrapper : IXmlSerializable, IDisposable {
> private string _fileName;
> private TempFileCollection tfc = null;
>>
> public string FileName { get { return _fileName; } }
>>
> public GetFileResponseWrapper ()
> : this(null) {
> }
>>
> public GetFileResponseWrapper (string fileName) {
> _fileName = fileName;
> // Manages the temp file that contains the file contents
> // Dispose this wrapper to clean up temp files.
> TempFileCollection tfc = new TempFileCollection();
> }
>>
> #region Dispose logic
> ~GetFileResponseWrapper () {
> Dispose(false);
> }
>>
> public void Dispose () {
> Dispose(true);
> }
>>
> void Dispose (bool isDisposing) {
> if (isDisposing && tfc != null)
> tfc.Delete();
> tfc = null;
> }
> #endregion
>>
> /// <summary>
> /// The schema for the file contents node is actually just
> /// base 64 binary data so return the qname of the schema
> /// type directly.
> /// </summary>
> public static XmlQualifiedName GetMySchema (XmlSchemaSet xss) {
> return new XmlQualifiedName("Base64Binary",
>"http://www.w3.org/2001/XMLSchema");
> }
>>
> /// <summary>
> /// Always return null.
> /// </summary>
> public XmlSchema GetSchema () { return null; }
>>
> /// <summary>
> /// Deserializes state out of an XmlReader
> /// </summary>
> public void ReadXml (XmlReader r) {
> // Read the open tag of the encapsulating element
> r.ReadStartElement();
>>
> //
> // Read the binary data that represents the file contents
> // into a temp file.
> //
> _fileName = tfc.AddExtension("fileContents", false);
> ReadContentsIntoFile(r, _fileName);
>>
> // Read the close tag of the encapsulating element
> r.ReadEndElement();
> }
>>
> /// <summary>
> /// Serializes state into an XmlWriter
> /// </summary>
> public void WriteXml (XmlWriter w) {
> using (FileStream fs = new FileStream(_fileName, FileMode.Open)) {
> byte[] buf = new byte[1024];
> int numRead = 0;
> while ((numRead = fs.Read(buf, 0, 1024)) 0) {
> w.WriteBase64(buf, 0, numRead);
> }
> }
> }
>>
> void ReadContentsIntoFile (XmlReader r, string fileName) {
> using (FileStream fs = new FileStream(fileName,
>FileMode.CreateNew)) {
> if (r.CanReadBinaryContent) {
> byte[] buf = new byte[1024];
> int numRead = 0;
> while ((numRead = r.ReadContentAsBase64(buf, 0, 1024)) >
>0) {
> fs.Write(buf, 0, numRead);
> }
> } else {
> throw new NotSupportedException();
> }
> }
> }
>}
>>
>
>

Champika Nirosh
Guest
 
Posts: n/a
#4: Oct 3 '06

re: Stream large file in WSE 3.0


I didn't read the link you gave but have a look here

http://msdn.microsoft.com/library/de...3f89f786bd.asp

and receiving part is even more simpler.. assuming that you know how to
create the proxy etc
byte[] response = serviceproxy.GetFile(fileName);
will let you access the binary stream received..

Nirosh.
Note: Please also refer to the sample given with the WSE 3.0.. check the
startup menu items.. under Microsoft WSE 3.0 >Document


"Hardy Wang" <hardywang@hotmail.comwrote in message
news:%23zFC7Hu5GHA.1012@TK2MSFTNGP05.phx.gbl...
Quote:
Thanks for your comment, I read this example from
ms-help://MS.WSE30.1033/WSE3.0/html/3e9ce678-2502-4847-9f13-5173896c9db5.htm
or from MS MSDN
http://msdn.microsoft.com/library/de...73896c9db5.asp
>
Any idea what should I do?
>
"Champika Nirosh" <test@tc.comwrote in message
news:OpQFQvs5GHA.4608@TK2MSFTNGP03.phx.gbl...
Quote:
>Hi,
>>
>To my knowledge if you are to utilize the WSE MTOM then you got to send
>your file as a byte[] not as a custom object at your will.. only the
>byte[] will recognize by the Optimization machanism..
>>
>The GetFileResponseWrapper will pass olny the single public property it
>has.. that is... FileName but in your case that also will not since it
>does not have the setter part, since the object serialization/
>deserialization is needed the set/ get both to send it via SOAP
>successfully... I think you are doing this very veyr wrong..
>>
>Since you said you are reading the help I will stop it here...
>>
>Nirosh.
>>
>object
>"Hardy Wang" <hardywang@hotmail.comwrote in message
>news:Oqxq2uo5GHA.3960@TK2MSFTNGP02.phx.gbl...
Quote:
>>Hi all,
>> I am new to WSE 3.0, and currently reading the document shipped with
>>installation. From sample provided (see below), I created WSE service
>>side code, but how can I consume stream returned by web method in my Web
>>Form application? I already configurated web.config of my web service by
>>running WSE 3.0 setting tool.
>>>
>>Thanks!
>>>
>>>
>>[WebMethod(BufferResponse = false)]
>>public GetFileResponseWrapper GetStream () {
>> String filePath = @"e:\temp\70ONEEL06COMP.pdf";
>> return new GetFileResponseWrapper(filePath);
>>}
>>>
>>>
>>using System;
>>using System.Data;
>>using System.Configuration;
>>using System.Web;
>>using System.Web.Security;
>>using System.Web.UI;
>>using System.Web.UI.WebControls;
>>using System.Web.UI.WebControls.WebParts;
>>using System.Web.UI.HtmlControls;
>>using System.IO;
>>using System.Xml;
>>using System.Xml.Serialization;
>>using System.Xml.Schema;
>>using System.CodeDom.Compiler;
>>>
>>/// <summary>
>>/// Summary description for GetFileResponseWrapper
>>/// </summary>
>>[XmlSchemaProvider("GetMySchema")]
>>public class GetFileResponseWrapper : IXmlSerializable, IDisposable {
>> private string _fileName;
>> private TempFileCollection tfc = null;
>>>
>> public string FileName { get { return _fileName; } }
>>>
>> public GetFileResponseWrapper ()
>> : this(null) {
>> }
>>>
>> public GetFileResponseWrapper (string fileName) {
>> _fileName = fileName;
>> // Manages the temp file that contains the file contents
>> // Dispose this wrapper to clean up temp files.
>> TempFileCollection tfc = new TempFileCollection();
>> }
>>>
>> #region Dispose logic
>> ~GetFileResponseWrapper () {
>> Dispose(false);
>> }
>>>
>> public void Dispose () {
>> Dispose(true);
>> }
>>>
>> void Dispose (bool isDisposing) {
>> if (isDisposing && tfc != null)
>> tfc.Delete();
>> tfc = null;
>> }
>> #endregion
>>>
>> /// <summary>
>> /// The schema for the file contents node is actually just
>> /// base 64 binary data so return the qname of the schema
>> /// type directly.
>> /// </summary>
>> public static XmlQualifiedName GetMySchema (XmlSchemaSet xss) {
>> return new XmlQualifiedName("Base64Binary",
>>"http://www.w3.org/2001/XMLSchema");
>> }
>>>
>> /// <summary>
>> /// Always return null.
>> /// </summary>
>> public XmlSchema GetSchema () { return null; }
>>>
>> /// <summary>
>> /// Deserializes state out of an XmlReader
>> /// </summary>
>> public void ReadXml (XmlReader r) {
>> // Read the open tag of the encapsulating element
>> r.ReadStartElement();
>>>
>> //
>> // Read the binary data that represents the file contents
>> // into a temp file.
>> //
>> _fileName = tfc.AddExtension("fileContents", false);
>> ReadContentsIntoFile(r, _fileName);
>>>
>> // Read the close tag of the encapsulating element
>> r.ReadEndElement();
>> }
>>>
>> /// <summary>
>> /// Serializes state into an XmlWriter
>> /// </summary>
>> public void WriteXml (XmlWriter w) {
>> using (FileStream fs = new FileStream(_fileName, FileMode.Open))
>>{
>> byte[] buf = new byte[1024];
>> int numRead = 0;
>> while ((numRead = fs.Read(buf, 0, 1024)) 0) {
>> w.WriteBase64(buf, 0, numRead);
>> }
>> }
>> }
>>>
>> void ReadContentsIntoFile (XmlReader r, string fileName) {
>> using (FileStream fs = new FileStream(fileName,
>>FileMode.CreateNew)) {
>> if (r.CanReadBinaryContent) {
>> byte[] buf = new byte[1024];
>> int numRead = 0;
>> while ((numRead = r.ReadContentAsBase64(buf, 0, 1024)) >
>>0) {
>> fs.Write(buf, 0, numRead);
>> }
>> } else {
>> throw new NotSupportedException();
>> }
>> }
>> }
>>}
>>>
>>
>>
>
>

Hardy Wang
Guest
 
Posts: n/a
#5: Oct 3 '06

re: Stream large file in WSE 3.0


Thanks, I already tried this solution before. My understanding is, it is not
stream, all dat will be read into memory then transfer to the other end
before we can use it.

Correct me if I am wrong.

"Champika Nirosh" wrote:
Quote:
I didn't read the link you gave but have a look here
>
http://msdn.microsoft.com/library/de...3f89f786bd.asp
>
and receiving part is even more simpler.. assuming that you know how to
create the proxy etc
byte[] response = serviceproxy.GetFile(fileName);
will let you access the binary stream received..
>
Nirosh.
Note: Please also refer to the sample given with the WSE 3.0.. check the
startup menu items.. under Microsoft WSE 3.0 >Document
>
>
"Hardy Wang" <hardywang@hotmail.comwrote in message
news:%23zFC7Hu5GHA.1012@TK2MSFTNGP05.phx.gbl...
Quote:
Thanks for your comment, I read this example from
ms-help://MS.WSE30.1033/WSE3.0/html/3e9ce678-2502-4847-9f13-5173896c9db5.htm
or from MS MSDN
http://msdn.microsoft.com/library/de...73896c9db5.asp

Any idea what should I do?

"Champika Nirosh" <test@tc.comwrote in message
news:OpQFQvs5GHA.4608@TK2MSFTNGP03.phx.gbl...
Quote:
Hi,
>
To my knowledge if you are to utilize the WSE MTOM then you got to send
your file as a byte[] not as a custom object at your will.. only the
byte[] will recognize by the Optimization machanism..
>
The GetFileResponseWrapper will pass olny the single public property it
has.. that is... FileName but in your case that also will not since it
does not have the setter part, since the object serialization/
deserialization is needed the set/ get both to send it via SOAP
successfully... I think you are doing this very veyr wrong..
>
Since you said you are reading the help I will stop it here...
>
Nirosh.
>
object
"Hardy Wang" <hardywang@hotmail.comwrote in message
news:Oqxq2uo5GHA.3960@TK2MSFTNGP02.phx.gbl...
>Hi all,
> I am new to WSE 3.0, and currently reading the document shipped with
>installation. From sample provided (see below), I created WSE service
>side code, but how can I consume stream returned by web method in my Web
>Form application? I already configurated web.config of my web service by
>running WSE 3.0 setting tool.
>>
>Thanks!
>>
>>
>[WebMethod(BufferResponse = false)]
>public GetFileResponseWrapper GetStream () {
> String filePath = @"e:\temp\70ONEEL06COMP.pdf";
> return new GetFileResponseWrapper(filePath);
>}
>>
>>
>using System;
>using System.Data;
>using System.Configuration;
>using System.Web;
>using System.Web.Security;
>using System.Web.UI;
>using System.Web.UI.WebControls;
>using System.Web.UI.WebControls.WebParts;
>using System.Web.UI.HtmlControls;
>using System.IO;
>using System.Xml;
>using System.Xml.Serialization;
>using System.Xml.Schema;
>using System.CodeDom.Compiler;
>>
>/// <summary>
>/// Summary description for GetFileResponseWrapper
>/// </summary>
>[XmlSchemaProvider("GetMySchema")]
>public class GetFileResponseWrapper : IXmlSerializable, IDisposable {
> private string _fileName;
> private TempFileCollection tfc = null;
>>
> public string FileName { get { return _fileName; } }
>>
> public GetFileResponseWrapper ()
> : this(null) {
> }
>>
> public GetFileResponseWrapper (string fileName) {
> _fileName = fileName;
> // Manages the temp file that contains the file contents
> // Dispose this wrapper to clean up temp files.
> TempFileCollection tfc = new TempFileCollection();
> }
>>
> #region Dispose logic
> ~GetFileResponseWrapper () {
> Dispose(false);
> }
>>
> public void Dispose () {
> Dispose(true);
> }
>>
> void Dispose (bool isDisposing) {
> if (isDisposing && tfc != null)
> tfc.Delete();
> tfc = null;
> }
> #endregion
>>
> /// <summary>
> /// The schema for the file contents node is actually just
> /// base 64 binary data so return the qname of the schema
> /// type directly.
> /// </summary>
> public static XmlQualifiedName GetMySchema (XmlSchemaSet xss) {
> return new XmlQualifiedName("Base64Binary",
>"http://www.w3.org/2001/XMLSchema");
> }
>>
> /// <summary>
> /// Always return null.
> /// </summary>
> public XmlSchema GetSchema () { return null; }
>>
> /// <summary>
> /// Deserializes state out of an XmlReader
> /// </summary>
> public void ReadXml (XmlReader r) {
> // Read the open tag of the encapsulating element
> r.ReadStartElement();
>>
> //
> // Read the binary data that represents the file contents
> // into a temp file.
> //
> _fileName = tfc.AddExtension("fileContents", false);
> ReadContentsIntoFile(r, _fileName);
>>
> // Read the close tag of the encapsulating element
> r.ReadEndElement();
> }
>>
> /// <summary>
> /// Serializes state into an XmlWriter
> /// </summary>
> public void WriteXml (XmlWriter w) {
> using (FileStream fs = new FileStream(_fileName, FileMode.Open))
>{
> byte[] buf = new byte[1024];
> int numRead = 0;
> while ((numRead = fs.Read(buf, 0, 1024)) 0) {
> w.WriteBase64(buf, 0, numRead);
> }
> }
> }
>>
> void ReadContentsIntoFile (XmlReader r, string fileName) {
> using (FileStream fs = new FileStream(fileName,
>FileMode.CreateNew)) {
> if (r.CanReadBinaryContent) {
> byte[] buf = new byte[1024];
> int numRead = 0;
> while ((numRead = r.ReadContentAsBase64(buf, 0, 1024)) >
>0) {
> fs.Write(buf, 0, numRead);
> }
> } else {
> throw new NotSupportedException();
> }
> }
> }
>}
>>
>
>
>
>
>
Champika Nirosh
Guest
 
Posts: n/a
#6: Oct 4 '06

re: Stream large file in WSE 3.0


Ops!.. I have not understand the requirement..
ok you want the data to be read while they are transfering..is that the
requirement? but this method is something new to me.. let me do a small R&D
while you are replying..

Nirosh.

"Hardy Wang" <HardyWang@discussions.microsoft.comwrote in message
news:8D95668B-29A8-436C-89D3-81C2B429B989@microsoft.com...
Quote:
Thanks, I already tried this solution before. My understanding is, it is
not
stream, all dat will be read into memory then transfer to the other end
before we can use it.
>
Correct me if I am wrong.
>
"Champika Nirosh" wrote:
>
Quote:
>I didn't read the link you gave but have a look here
>>
>http://msdn.microsoft.com/library/de...3f89f786bd.asp
>>
>and receiving part is even more simpler.. assuming that you know how to
>create the proxy etc
>byte[] response = serviceproxy.GetFile(fileName);
>will let you access the binary stream received..
>>
>Nirosh.
>Note: Please also refer to the sample given with the WSE 3.0.. check the
>startup menu items.. under Microsoft WSE 3.0 >Document
>>
>>
>"Hardy Wang" <hardywang@hotmail.comwrote in message
>news:%23zFC7Hu5GHA.1012@TK2MSFTNGP05.phx.gbl...
Quote:
Thanks for your comment, I read this example from
ms-help://MS.WSE30.1033/WSE3.0/html/3e9ce678-2502-4847-9f13-5173896c9db5.htm
or from MS MSDN
http://msdn.microsoft.com/library/de...73896c9db5.asp
>
Any idea what should I do?
>
"Champika Nirosh" <test@tc.comwrote in message
news:OpQFQvs5GHA.4608@TK2MSFTNGP03.phx.gbl...
>Hi,
>>
>To my knowledge if you are to utilize the WSE MTOM then you got to
>send
>your file as a byte[] not as a custom object at your will.. only the
>byte[] will recognize by the Optimization machanism..
>>
>The GetFileResponseWrapper will pass olny the single public property
>it
>has.. that is... FileName but in your case that also will not since
>it
>does not have the setter part, since the object serialization/
>deserialization is needed the set/ get both to send it via SOAP
>successfully... I think you are doing this very veyr wrong..
>>
>Since you said you are reading the help I will stop it here...
>>
>Nirosh.
>>
>object
>"Hardy Wang" <hardywang@hotmail.comwrote in message
>news:Oqxq2uo5GHA.3960@TK2MSFTNGP02.phx.gbl...
>>Hi all,
>> I am new to WSE 3.0, and currently reading the document shipped
>>with
>>installation. From sample provided (see below), I created WSE service
>>side code, but how can I consume stream returned by web method in my
>>Web
>>Form application? I already configurated web.config of my web service
>>by
>>running WSE 3.0 setting tool.
>>>
>>Thanks!
>>>
>>>
>>[WebMethod(BufferResponse = false)]
>>public GetFileResponseWrapper GetStream () {
>> String filePath = @"e:\temp\70ONEEL06COMP.pdf";
>> return new GetFileResponseWrapper(filePath);
>>}
>>>
>>>
>>using System;
>>using System.Data;
>>using System.Configuration;
>>using System.Web;
>>using System.Web.Security;
>>using System.Web.UI;
>>using System.Web.UI.WebControls;
>>using System.Web.UI.WebControls.WebParts;
>>using System.Web.UI.HtmlControls;
>>using System.IO;
>>using System.Xml;
>>using System.Xml.Serialization;
>>using System.Xml.Schema;
>>using System.CodeDom.Compiler;
>>>
>>/// <summary>
>>/// Summary description for GetFileResponseWrapper
>>/// </summary>
>>[XmlSchemaProvider("GetMySchema")]
>>public class GetFileResponseWrapper : IXmlSerializable, IDisposable {
>> private string _fileName;
>> private TempFileCollection tfc = null;
>>>
>> public string FileName { get { return _fileName; } }
>>>
>> public GetFileResponseWrapper ()
>> : this(null) {
>> }
>>>
>> public GetFileResponseWrapper (string fileName) {
>> _fileName = fileName;
>> // Manages the temp file that contains the file contents
>> // Dispose this wrapper to clean up temp files.
>> TempFileCollection tfc = new TempFileCollection();
>> }
>>>
>> #region Dispose logic
>> ~GetFileResponseWrapper () {
>> Dispose(false);
>> }
>>>
>> public void Dispose () {
>> Dispose(true);
>> }
>>>
>> void Dispose (bool isDisposing) {
>> if (isDisposing && tfc != null)
>> tfc.Delete();
>> tfc = null;
>> }
>> #endregion
>>>
>> /// <summary>
>> /// The schema for the file contents node is actually just
>> /// base 64 binary data so return the qname of the schema
>> /// type directly.
>> /// </summary>
>> public static XmlQualifiedName GetMySchema (XmlSchemaSet xss) {
>> return new XmlQualifiedName("Base64Binary",
>>"http://www.w3.org/2001/XMLSchema");
>> }
>>>
>> /// <summary>
>> /// Always return null.
>> /// </summary>
>> public XmlSchema GetSchema () { return null; }
>>>
>> /// <summary>
>> /// Deserializes state out of an XmlReader
>> /// </summary>
>> public void ReadXml (XmlReader r) {
>> // Read the open tag of the encapsulating element
>> r.ReadStartElement();
>>>
>> //
>> // Read the binary data that represents the file contents
>> // into a temp file.
>> //
>> _fileName = tfc.AddExtension("fileContents", false);
>> ReadContentsIntoFile(r, _fileName);
>>>
>> // Read the close tag of the encapsulating element
>> r.ReadEndElement();
>> }
>>>
>> /// <summary>
>> /// Serializes state into an XmlWriter
>> /// </summary>
>> public void WriteXml (XmlWriter w) {
>> using (FileStream fs = new FileStream(_fileName,
>>FileMode.Open))
>>{
>> byte[] buf = new byte[1024];
>> int numRead = 0;
>> while ((numRead = fs.Read(buf, 0, 1024)) 0) {
>> w.WriteBase64(buf, 0, numRead);
>> }
>> }
>> }
>>>
>> void ReadContentsIntoFile (XmlReader r, string fileName) {
>> using (FileStream fs = new FileStream(fileName,
>>FileMode.CreateNew)) {
>> if (r.CanReadBinaryContent) {
>> byte[] buf = new byte[1024];
>> int numRead = 0;
>> while ((numRead = r.ReadContentAsBase64(buf, 0, 1024))
>> >
>>0) {
>> fs.Write(buf, 0, numRead);
>> }
>> } else {
>> throw new NotSupportedException();
>> }
>> }
>> }
>>}
>>>
>>
>>
>
>
>>
>>
>>

Closed Thread