Ask the Expert

How can I create a SoapExtension for my Web service?

I'm trying to create a SoapExtension for my Web services. I've written my own extension, bought a book and installed the samples and even downloaded samples. Everything looks good but the SoapExtension objects never get instantiated. The GetInitializer never gets called in any of them. I've tried both the web.config and attributes to get it to hook in. Is there some global setting somewhere I am missing or something?

    Requires Free Membership to View

Well, a SOAP extension is configured in one of 2 places for ASP.NET to use it. Are you using it locally to an application or globally on the server? After building a SoapExtension, it can be configured to be used for just a single directory, or for all applications on the server.

To set it up for a single virtual directory, start by placing the assembly in the local bin directory. Next modify web.config as follows to direct ASP.NET to load your new extension:

If it does not already exist, create a new element under <system.web> called <webServices>. then create a <soapExtensionTypes> element under that. Here is an example extension web.config entry from MSDN:

<webServices>
    <soapExtensionTypes>
        <add type="PrioritySoapHeaderExtension.PriorityHeaderExtension,
                   PrioritySoapHeaderExtension" 
              priority="1" 
              group="0" /> 
    </soapExtensionTypes>
</webServices>

The type attribute of the add element indicates the class type that implements the SoapExtension with the added assembly name after the comma. The priority and group elements allow you to make settings so that you have some control over the order in which this extension will be loaded.

If you want your extension to be available globally for all virtual directories, you will need to place it in the Global Assembly Cache or GAC. You must be assured you have given your assembly a strong name. For more information see the following link in MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service06182002.asp


This was first published in August 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: