Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3336144
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:06:03+00:00 2026-05-18T00:06:03+00:00

In my application, I’m calling a web service and by using SoapExtension and SoapExtensionAttribute

  • 0

In my application, I’m calling a web service and by using SoapExtension and SoapExtensionAttribute I can intercept the incoming and outgoing SOAP messages for logging purposes. I used the example in http://msdn.microsoft.com/en-us/magazine/cc164007.aspx as input.
But now I want to go one step further. I have a Windows client that calls my class (in a separate project) and the class then calls the web service. I can now intercept the SOAP messages, but instead of directly logging them to a file, I want to pass those messages back to my class that is calling the web service and also back to the client that is calling my class. These are the code changes I have made so far:

        private String ExtractFromStream(Stream target)
    {
        if (target != null)
            return (new StreamReader(target)).ReadToEnd();

        return "";
    }

    public void WriteOutput(SoapMessage message)
    {
        newStream.Position = 0;
        string soapOutput = ExtractFromStream(newStream);

        newStream.Position = 0;
        Copy(newStream, oldStream);
    }

    public void WriteInput(SoapMessage message)
    {
        Copy(oldStream, newStream);

        newStream.Position = 0;
        string soapInput= ExtractFromStream(newStream);
        newStream.Position = 0;
    }

I now want to pass the soapInput and soapOutput back to the class that holds the method that this attribute is applied on. Any clues on how I should do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:06:03+00:00Added an answer on May 18, 2026 at 12:06 am

    For anyone that happens to pass by, here is the solution:

    The SoapMessage object does not contain any information about my client. However, I can cast this object to a SoapClientMessage object and then I will have access to my web service. If I now add a method to this webservice (by creating a new public partial class) I can access its properties and methods like this (purely an example!):

     private String ExtractFromStream(Stream target)
        {
            if (target != null)
                return (new StreamReader(target)).ReadToEnd();
    
            return "";
        }
    
    
    
        public void WriteOutput(SoapMessage message)
        {
            newStream.Position = 0;
    
            string soapOutput = ExtractFromStream(newStream);
            SoapClientMessage soapClient = (SoapClientMessage)message;
            WebServiceClass webservice = (WebServiceClass)soapClient.Client;
            webservice.MyMethod(soapOutput); //Use your own method here!
    
    
            newStream.Position = 0;
            Copy(newStream, oldStream);
        }
    
        public void WriteInput(SoapMessage message)
        {
            Copy(oldStream, newStream);           
            newStream.Position = 0;
    
            string soapInput= ExtractFromStream(newStream);
            SoapClientMessage soapClient = (SoapClientMessage)message;
            WebServiceClass webservice = (WebServiceClass)soapClient.Client;
            webservice.MyMethod(soapInput);
            newStream.Position = 0;
        }
    

    You can add methods (like the MyMethod in this example) to your WebServiceClass by creating a new public partial class and adding methods, properties and anything you like to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Application db connection in web service. i haveto connect the db using that web
Application pool for my web service has Identity set to myDomain\myUser. When I run
Application configuration: Web application using java first method of creating JAX-WS 2.0 Web Services
Application launch through Java web start(JWS) checks for update when we are launching it.
Application works fine. I can access everything in debug except for an Array Adapter
Our application takes text from a web form and sends it via email to
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
Application: This is a workshop proposal system for a conference. A user can create
The application crashes on the row: [uids addObject:user.uid]; Who can tell why??
My application that is not on Play Store verify on the web If there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.