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
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