首页 / C# / c# – 通过配置进行WCF模拟
c# – 通过配置进行WCF模拟
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – 通过配置进行WCF模拟,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2330字,纯文字阅读大概需要4分钟。
内容图文
![c# – 通过配置进行WCF模拟](/upload/InfoBanner/zyjiaocheng/783/3efc469f0936432da52ffd2b5d85ace3.jpg)
我有一个使用WSHttpBinding和Windows身份验证的简单WCF服务.我试图强制服务器在每次调用此服务的方法时模拟客户端的身份.
我尝试了WCF Service Impersonation给出的建议,但结果并不完美.当我尝试导航到WCF服务的登录页面时,我看到错误:
The contract operation ‘GetAdvice’
requires Windows identity for
automatic impersonation. A Windows
identity that represents the caller is
not provided by binding
(‘WSHttpBinding’,’07001′)
for contract
(‘IMagicEightBallService’,’07001′.
关于这个错误试图告诉我的任何想法?
可以在ftp://petio.org/2011/07/01/magiceightball/浏览整个解决方案(或在http://petio.org/2011/07/01/MagicEightBall.zip下载).我只是将项目发布到本地IIS文件夹并在http://localhost/MagicEightBall/MagicEightBallService.svc访问该服务.
谢谢!
更新:
我的服务的Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Petio.MagicEightBall.MagicEightBallService" behaviorConfiguration="MagicEightBallServiceBehavior">
<endpoint name="WSHttpBinding_WindowsSecurity_IMagicEightBallService"
address="http://localhost/MagicEightBall/MagicEightBallService.svc"
binding="wsHttpBinding"
contract="Petio.MagicEightBall.IMagicEightBallService" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MagicEightBallServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization impersonateCallerForAllOperations="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我的服务代码:
public class MagicEightBallService : IMagicEightBallService
{
[OperationBehavior(Impersonation=ImpersonationOption.Required)]
public string GetAdvice()
{
MagicEightBall ball = new MagicEightBall();
return ball.GetAdvice();
}
}
解决方法:
如何将整个问题最小化到最简单的可重现代码,您可以在这里简单地显示?没有人有兴趣下载和审查整个项目.此外,为了以后的参考,相关的代码应该仍然在这里.
我检查了您的项目和客户端代码的正确配置,我看到两个阻塞问题:
>如果要从配置强制执行模拟,则必须仅使用带有Windows身份验证的绑定 – 通过HTTPS公开的端点无需身份验证.
> WCF中的模拟还要求客户端允许服务模拟其身份,因此在服务上设置配置是不够的.
Here你有一些关于模仿的文章和所有必要/可能的设置.
内容总结
以上是互联网集市为您收集整理的c# – 通过配置进行WCF模拟全部内容,希望文章能够帮你解决c# – 通过配置进行WCF模拟所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。