Note that there are some explanatory texts on larger screens.

plurals
  1. POSOAP Extension Stream Empty After Serialization
    primarykey
    data
    text
    <p>I have had this problem for the last day. I have created a SOAP Extension following the MSDN articles and a load of blog posts but I just can't get it to work. Ok Some code:</p> <pre><code>public class EncryptionExtension : SoapExtension { Stream _stream; public override object GetInitializer(Type serviceType) { return typeof(EncryptionExtension); } public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute) { return attribute; } public override void Initialize(object initializer) { } public override void ProcessMessage(SoapMessage message) { switch (message.Stage) { case SoapMessageStage.BeforeSerialize: break; case SoapMessageStage.AfterSerialize: break; case SoapMessageStage.BeforeDeserialize: break; case SoapMessageStage.AfterDeserialize: break; default: throw new Exception("invalid stage"); } } public override Stream ChainStream(Stream stream) { _stream = stream; return stream; } } </code></pre> <p>There is also an attribute class:</p> <pre><code>[AttributeUsage(AttributeTargets.Method)] public class EncryptionExtensionAttribute : SoapExtensionAttribute { public override Type ExtensionType { get { return typeof(EncryptionExtension); } } public override int Priority { get; set; } } </code></pre> <p>So when the message comes in I can see the inbound SOAP request when I debug at the BeforeDeserialization and AfterDeserialization, which is great. My web service method is then called. Which is simply:</p> <pre><code>[WebMethod()] [EncryptionExtension] public string HelloWorld() { return "Hello world"; } </code></pre> <p>The process then hops back into my SoapExtension. Putting break points at BeforeSerialization and AfterSerialization I see that the outbound stream contains nothing. I am not surprised that it is empty on the BeforeSerialization but i am surprised that it is empty at AfterSerialization. This creates a problem because I need to get hold of the outbound stream so I can encrypt it. </p> <p>Can someone tell me why the outbound stream is empty? I have followed this MSDN article which indiciates it shouldn't be <a href="http://msdn.microsoft.com/en-us/library/ms972410.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms972410.aspx</a>. Am I missing some configuration or something else?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload