SoapExtension logging to SQL

  • Thread starter Mark A. Richman
  • Start date
M

Mark A. Richman

Does anyone have an example of a SoapExtension that writes the incoming SOAP request to a table via SQL? I have tried editing the TraceExtension sample code on MSDN with little success.

I am not entirely sure what the newStream/oldStream members would be used for in a SQL logging scenario. I just want to inspect the incoming message, not modify it. From the API docs, it doesn't look like I'd need to override ChainStream() at all.

Any ideas?
 
D

Dino Chiesa [Microsoft]

(removing a few groups)
I haven't done this but it shouldn't be difficult. what do you mean "with
little success"? what problems did you encounter?
-Dino


Does anyone have an example of a SoapExtension that writes the incoming SOAP
request to a table via SQL? I have tried editing the TraceExtension sample
code on MSDN with little success.

I am not entirely sure what the newStream/oldStream members would be used
for in a SQL logging scenario. I just want to inspect the incoming message,
not modify it. From the API docs, it doesn't look like I'd need to override
ChainStream() at all.

Any ideas?
 
M

Mark A. Richman

I forgot to set the message.Stream.Position = 0 before I exited my SoapExtension! I do not need to use ChainStream either:

public override void ProcessMessage(SoapMessage message)
{
switch(message.Stage)
{
case SoapMessageStage.BeforeSerialize:
break;
case SoapMessageStage.AfterSerialize:
break;
case SoapMessageStage.BeforeDeserialize:
WriteInput(message);
break;
case SoapMessageStage.AfterDeserialize:
break;
default:
throw new Exception("invalid stage");
}
}

/// <summary>
/// Writes the incoming SOAP message to SQL
/// </summary>
/// <param name="message"></param>
private void WriteInput(SoapMessage message)
{
System.IO.StreamReader sr = new System.IO.StreamReader(message.Stream);
parameters = sr.ReadToEnd();

object[] parms = { parameters };

SqlHelper.ExecuteNonQuery(con, "InsertSoapMessage", parms);

message.Stream.Position = 0;
}
}

--
MARK RICHMAN
(removing a few groups)
I haven't done this but it shouldn't be difficult. what do you mean "with
little success"? what problems did you encounter?
-Dino


Does anyone have an example of a SoapExtension that writes the incoming SOAP
request to a table via SQL? I have tried editing the TraceExtension sample
code on MSDN with little success.

I am not entirely sure what the newStream/oldStream members would be used
for in a SQL logging scenario. I just want to inspect the incoming message,
not modify it. From the API docs, it doesn't look like I'd need to override
ChainStream() at all.

Any ideas?
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top