大家好..。
显然,我没有为我的WCF服务设置正确的模拟。我不想在一个方法的基础上设置安全性(在实际代码隐藏中)。该服务(目前)开放供intranet上的每个人调用。
所以我的问题是…
问:我遗漏了哪些web-config标签?
问:我需要在web中更改什么才能使模拟工作?
服务Web.config看起来像.
<configuration>
<system.web>
<authorization>
<allow users="?"/>
</authorization>
<authentication mode="Windows"/>
<identity impersonate="true" userName="MyDomain\MyUser" password="MyPassword"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="wcfFISH.DataServiceBehavior" name="wcfFISH.DataService">
<endpoint address="" binding="wsHttpBinding" contract="wcfFISH.IFishData">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfFISH.DataServiceBehavior">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>发布于 2010-04-20 17:35:24
如果您总是希望模拟所有操作的客户端,那么将以下内容添加到<behavior>元素中,即在<serviceMetadata>元素之后:
<serviceAuthorization impersonateCallerForAllOperations="true" />如果您试图在应用程序级别模拟,则通常不能在WCF中这样做,因为WCF实际上不是ASP.NET管道的一部分。
最简单的解决方法是将WCF应用程序放在自己的application中,并将池的进程标识设置为您想要模拟的.用户。
另一种方法是打开ASP.NET兼容模式,将其添加到<system.servicemodel>中
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>你有时还需要用以下方式来装饰你的服务:
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]但请记住,这将限制您利用许多其他较新的WCF特性,如MSMQ或TCP绑定的能力。我更喜欢隔离的应用程序池方法。
https://stackoverflow.com/questions/2677224
复制相似问题