SoapExtension Stream proeprty doesn't work...

  • Thread starter Pieter Philippaerts
  • Start date
P

Pieter Philippaerts

Hello,

I'm writing a SoapExtension that processes SoapServerMessages. At one point
in the BeforeSerialize or AfterSerialize phase, I need access to the body of
the SOAP message. I though I could use the SoapMessage.Stream property
because it can be used to view the data at each SoapMessageStage, but
whenever I try to read data from the returned Stream I get an exception.

These are the exception I get when trying to read from the stream during the
BeforeSerialize or AfterSerialize stages:

An unhandled exception of type 'System.Web.Services.Protocols.SoapException'
occurred in system.web.services.dll
Additional information: System.Web.Services.Protocols.SoapException: Server
was unable to process request. ---> System.NotSupportedException: Specified
method is not supported.
at System.Web.HttpResponseStream.Read(Byte[] buffer, Int32 offset, Int32
count)
at System.Web.Services.Protocols.SoapExtensionStream.Read(Byte[] buffer,
Int32 offset, Int32 count)
at System.Xml.XmlStreamReader.Read(Byte[] data, Int32 offset, Int32
length)
at System.Xml.XmlScanner..ctor(XmlStreamReader reader, XmlNameTable
ntable, Encoding enc)
at System.Xml.XmlTextReader..ctor(String url, Stream input, XmlNameTable
nt)
at System.Xml.XmlTextReader..ctor(String url, Stream input)
at System.Security.Cryptography.Xml.CanonicalXml..ctor(Stream
inputStream, Boolean includeComments, XmlResolver resolver, String
strBaseUri)
at System.Security.Cryptography.Xml.XmlDsigC14NTransform.LoadInput(Object
obj)
at ExtensionModule.MyExtension.ProcessMessage(SoapMessage message)
at
System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[]
extensions)
at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[]
returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[]
returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
--- End of inner exception stack trace ---

An unhandled exception of type 'System.Web.Services.Protocols.SoapException'
occurred in system.web.services.dll
Additional information: System.Web.Services.Protocols.SoapException: Server
was unable to process request. ---> System.InvalidOperationException:
Properties and methods of the stream can't be accessed in the
BeforeSerialize stage.
at System.Web.Services.Protocols.SoapExtensionStream.EnsureStreamReady()
at System.Web.Services.Protocols.SoapExtensionStream.get_CanSeek()
at System.Xml.XmlStreamReader.get_CanCalcLength()
at System.Xml.XmlScanner..ctor(XmlStreamReader reader, XmlNameTable
ntable, Encoding enc)
at System.Xml.XmlTextReader..ctor(String url, Stream input, XmlNameTable
nt)
at System.Xml.XmlTextReader..ctor(String url, Stream input)
at System.Security.Cryptography.Xml.CanonicalXml..ctor(Stream
inputStream, Boolean includeComments, XmlResolver resolver, String
strBaseUri)
at System.Security.Cryptography.Xml.XmlDsigC14NTransform.LoadInput(Object
obj)
at ExtensionModule.MyExtension.ProcessMessage(SoapMessage message)
at
System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[]
extensions)
at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[]
returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[]
returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
--- End of inner exception stack trace ---


Any thoughts on how I can use the Stream property, or is there another
method to get the contents of the SOAP body?

Regards,
Pieter Philippaerts
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top