I need to use a SoapExtension
subclass (which I have created), but it seems that this class can only be initialized through a web.config
file. I have read that it should be possible through app.config
file, but I don't know how to do it that way.
Problem: I don't have a web.config
file in my project.
So I created one manually with the following content:
<?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 breakpoints dispatched in each SoapExtension methods, nothing happens at runtime, it seems that it is never initialized nore called. My SoapService initializes ok, but without any extension.
I guess that creating the web.config file manually may not be enough for it to be taken into account, so I am wondering how to properly configure my app to have a web.config file in order to use my SoapExtension. It should go and initialize my class, processMessage, and chainStream stuff.
Note: This is my first ever SoapExtension implementation, so I am not really sure about what I am doing.
I found out how to / where to insert the web.config
content in the app.config file:
I had to insert it after ApplicationSettings
and userSettings
elements. This is the only place where it doesn't generate any error at runtime. So no need for a web.config file, although I still would like to know how to configure the app, if someone has the 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>
My SoapExtension seems to be correctly initialized now, and the message filtering works fine.
Related to @soleshoe's comment I couldn't get my Unit tests (XUnit) to work, my App.config looked like this in 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With