我需要使用一个SoapExtension
子类(我创建的),但似乎这个类只能通过web.config
文件。我读过这应该可以通过app.config
文件,但我不知道该怎么做。
Problem: 我没有web.config
文件在我的项目中。
所以我手动创建了一个包含以下内容的内容:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<webServices>
<soapExtensionTypes>
<add type="MyNameSpace.MySoapExtension,MyAssemblyFileName" priority="1"/>
</soapExtensionTypes>
</webServices>
</system.web>
</configuration>
尽管在每个 SoapExtension 方法中调度了断点,但运行时没有任何反应,似乎它从未初始化或调用。我的 SoapService 初始化正常,但没有任何扩展。
我想手动创建 web.config 文件可能不足以考虑它,所以我想知道如何正确配置我的应用程序以拥有 web.config 文件以便使用我的 SoapExtension。它应该去初始化我的类、processMessage 和 chainStream 内容。
Note:这是我第一次实现 SoapExtension,所以我不太确定我在做什么。
我找到了如何/在哪里插入web.config
app.config 文件中的内容:
我必须在之后插入它ApplicationSettings
and userSettings
元素。这是唯一在运行时不会生成任何错误的地方。因此不需要 web.config 文件,尽管我仍然想知道如何配置应用程序(如果有人有答案)。
<?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>
我的 SoapExtension 现在似乎已正确初始化,并且消息过滤工作正常。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)