SoapMessage.Stream Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the data representing the SOAP request or SOAP response in the form of a Stream.

Namespace:   System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)

public Stream Stream { get; }

Property Value

Type: System.IO.Stream

A read-only instance of the Stream class.

SOAP extensions that inspect the data representing a SOAP request or SOAP response, such as a logging SOAP extension, can use the Stream property to view the data at each SoapMessageStage.

SOAP extensions that modify the data representing a SOAP request or SOAP response, such as encryption or compression SOAP extensions, should do so with the Stream passed into the ChainStream method of SoapExtension. The Stream property of SoapMessage passed into ProcessMessage is read-only.

For more information on modifying the data representing a SOAP request or SOAP response, see ChainStream.

// Write the contents of the incoming SOAP message to the log file.
public void WriteInputBeforeDeserialize(SoapMessage myMessage)
   Copy(myOldStream, myNewStream);
   FileStream myFileStream = 
      new FileStream(myFileName, FileMode.Append, FileAccess.Write);
   StreamWriter myStreamWriter = new StreamWriter(myFileStream);
      "---------------------------------- Response at " + DateTime.Now);     
   Stream myStream = myMessage.Stream;
   myStreamWriter.Write("Length of data in the current response: ");
   myNewStream.Position = 0;
   Copy(myNewStream, myFileStream);
   myNewStream.Position = 0;

.NET Framework
Available since 1.1
Return to top