Q

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?

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

Dig deeper on Simple Object Access Protocol (SOAP)

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

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:

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close