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 264505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:41:28+00:00 2026-05-11T22:41:28+00:00

I am using a class in a C# ASP.NET project to allow a script

  • 0

I am using a class in a C# ASP.NET project to allow a script written in some random scripting language to expose webservice methods dynamically – in other words, the script should be able to expose a method of any name with any signature (as long as it’s valid, anyway) to the outside world through this SOAP interface (able to add and remove them at will, without needing a hard code change), and as such I need to be able to create a webservice class in C# while being able to dynamically add and remove methods at runtime.

Now, the best plan I’ve been able to come up with so far is (runtime) generating C# code to represent the webservice, using System.Reflection.Emit to compile it and then loading the assembly at runtime – all whenever the script adds or removes a method to/from the service (should not happen very often, mind).

Does anyone have a better idea than this?

  • 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-11T22:41:28+00:00Added an answer on May 11, 2026 at 10:41 pm

    You can modify WSDL by using SoapExtensionReflector class. From Kirk Evans Blog:

    The SoapExtensionReflector is called when your type is being reflected over to provide the WSDL definition for your service. You can leverage this type to intercept the reflection call and modify the WSDL output.

    The following example removes the first method out of 2 web service methods:

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {
       [WebMethod]
       public string HelloWorld()
       {
          return "Hello World";
       }
    
       [WebMethod]
       public int Multiply(int a, int b)
       {
          return a * b;
       }
    }
    

    Create a class inherited from SoapExtensionReflector:

    namespace TestWebservice
    {
       public class MyReflector : SoapExtensionReflector
       {
          public override void ReflectMethod()
          {
             //no-op
          }
    
          public override void ReflectDescription()
          {
             ServiceDescription description = ReflectionContext.ServiceDescription;
             if (description.PortTypes[0].Operations.Count == 2)
                description.PortTypes[0].Operations.RemoveAt(0);
             if (description.Messages.Count == 4)
             {
                description.Messages.RemoveAt(0);
                description.Messages.RemoveAt(0);
             }
             foreach (Binding binding in description.Bindings)
             {
                if (binding.Operations.Count == 2)
                   binding.Operations.RemoveAt(0);
             }
             if (description.Types.Schemas[0].Items.Count == 4)
             {
                description.Types.Schemas[0].Items.RemoveAt(0);
                description.Types.Schemas[0].Items.RemoveAt(0);
             }
          }
       }
    }
    

    Add this to configuration/system.web section in web.config:

    <webServices>
       <soapExtensionReflectorTypes>
          <add type="TestWebservice.MyReflector, TestWebservice" />
       </soapExtensionReflectorTypes>
    </webServices>
    

    This should give you a starting point to dynamically removing methods from WSDL document. You would also need to throw NotImplementedException from web method if it is disabled.

    Finally, you need to disable web service documentation produced by invoking .asmx endpoint without ?WSDL parameter. Set href attribute of wsdlHelpGenerator element to some URL. You can use DefaultWsdlHelpGenerator.aspx as a starting point for your own documentation handler. See question on web service documentation in XML Files, August 2002.

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

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Multiple tables help in the following ways / cases: (a)… May 12, 2026 at 12:43 am
  • Editorial Team
    Editorial Team added an answer Use HSSFCellStyle, that class has a method called setRotation(short rotation)… May 12, 2026 at 12:43 am
  • Editorial Team
    Editorial Team added an answer Added as an answer instead of a comment so I… May 12, 2026 at 12:43 am

Related Questions

At the moment I am working on a project admin application in C# 3.5
I am a newbie and developing a website using ASP .Net 2.0 with C#
I am using SqlMetal to general my DataContext.dbml class for my ASP.net application using
I have class which has a method that needs to return three DataTables. I
The spreadsheet still displays, but with the warning message. The problem seems to occur

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.