![](/img/trans.png)
[英]Windows Phone 7 Application + WCF + SSL + Username Authentication
[英]WCF with Windows Phone 7: Sending username over transport
我已使用自定义绑定创建了启用Silverlight的WCF服务,以根据指南传输二进制消息。 通过添加httpsTransport条目并在本地IIS实例上安装Verisign CA,我能够通过电话模拟器通过https调用此服务。 到现在为止还挺好。
我将安全性条目添加到绑定中,并将服务凭据添加到使用自定义类的行为中。 当通过客户端代理提交有效的用户名/密码对时,此服务和自定义类在单元测试中可以正常工作。
当我从WP7仿真器执行相同操作时,将收到“ MessageSecurityException”。
我的服务配置如下。 关于如何调试的任何想法或指针? 谢谢...
<system.serviceModel>
<bindings>
<customBinding>
<binding name="SimpleService.Simple.customBinding0">
<security authenticationMode="UserNameOverTransport"/>
<binaryMessageEncoding />
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<services>
<service name="SimpleService.Simple">
<endpoint address="" binding="customBinding" bindingConfiguration="SimpleService.Simple.customBinding0"
contract="SimpleService.Simple" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SimpleService.MyValidator,SimpleService"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
再次感谢..
多亏了我的同事Yossi Dahan,我得以使用Visual Studio中的WCF服务配置编辑器将跟踪添加到服务的Web.config中,然后使用Microsoft Service Trace Viewer来分析日志。
这表明请求正在到达服务器,但是自定义验证器抛出异常。
通过从VS中附加到IIS,我可以调试自定义验证器,以发现(令人尴尬的)我的WP7测试通过了无效的用户凭据-因此,一切工作正常!
获得的经验教训-在使用新技术时获得正确的跟踪/工具。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.