How to create a web.config file to load SoapExtension?

I need to use the SoapExtension subclass (which I created), but it seems that this class can only be initialized through the "web.config" file (although I read that this should be possible through the "app.config" file - but I don’t know how to do it). Problem: I do not have a web.config file in my project. Therefore, I created it manually with the following contents:

<?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <webServices> <soapExtensionTypes> <add type="MyNameSpace.MySoapExtension,MyAssemblyFileName" priority="1"/> </soapExtensionTypes> </webServices> </system.web> </configuration> 

Despite the fact that breakpoints passed in each SoapExtension method do not happen at runtime, it seems that it is never initialized with nore called ... (My SoapService initializes ok, but without any extension).

I think that creating a web.config file manually may not be enough to account for it, so I am wondering how to properly configure my application to have a web.config file to use my SoapExtension (It should go and initialize my class, processMessage and chainStream things...).

(Note: this is my first SoapExtension implementation, I'm not sure what I'm doing)

+6
c # web-services web-config asmx soap-extension
source share
2 answers

I found out how (or really "where") to insert the contents of web.config into the app.config file:

I had to insert it after "ApplicationSettings" and "userSettings"; this is the only place where it does not generate any errors at runtime (so there is no need for a web.config file, although I would still like to know how to configure the application if someone has an answer ...).

 <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <applicationSettings> </applicationSettings> <userSettings> </userSettings> <system.web> <webServices> <soapExtensionTypes> <add type="MyNameSpace.MySoapExtension,MyAssemblyFileName" priority="1"/> </soapExtensionTypes> </webServices> </system.web> <system.serviceModel> <bindings /> <client /> </system.serviceModel> </configuration> 

Now My SoapExtension is correctly initialized, message filtering works fine.

+11
source share

Due to the @soleshoe comment, I was not able to get my unit tests (XUnit) to work, my App.config looked like this at the end.

  <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <system.web> <webServices> <soapExtensionTypes> <add type="System.Common.SOAPExtensions.TraceExtension, System.Common" priority="1"/> </soapExtensionTypes> </webServices> </system.web> </configuration> 
0
source share

All Articles