How to create a web.config file to get SoapExtension loading?

后端 未结 2 1215
礼貌的吻别
礼貌的吻别 2021-01-18 04:13

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 ha

相关标签:
2条回答
  • 2021-01-18 04:50

    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.

    0 讨论(0)
  • 2021-01-18 05:09

    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>
    
    0 讨论(0)
提交回复
热议问题