SoapExtension logging to SQL

Discussion in 'ASP .Net Web Services' started by Mark A. Richman, Dec 1, 2004.

  1. 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?

    --
    MARK RICHMAN
     
    Mark A. Richman, Dec 1, 2004
    #1
    1. Advertising

  2. (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


    "Mark A. Richman" <> wrote in message
    news:%...
    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?

    --
    MARK RICHMAN
     
    Dino Chiesa [Microsoft], Dec 1, 2004
    #2
    1. Advertising

  3. 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
    "Dino Chiesa [Microsoft]" <> wrote in message news:...
    (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


    "Mark A. Richman" <> wrote in message
    news:%...
    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?

    --
    MARK RICHMAN
     
    Mark A. Richman, Dec 1, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fred carter

    SoapExtension & Http headers

    fred carter, Apr 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    798
    fred carter
    Apr 2, 2004
  2. Ted A W
    Replies:
    0
    Views:
    378
    Ted A W
    Jan 12, 2006
  3. VSK
    Replies:
    0
    Views:
    253
  4. VSK
    Replies:
    0
    Views:
    104
  5. VSK
    Replies:
    0
    Views:
    126
Loading...

Share This Page