【发布时间】:2011-06-30 05:53:05
【问题描述】:
我目前正在使用Self-Hosted SL Svc 模板开发自托管在Windows 服务中的WCF 服务。 该模板可以正常工作,并且我可以从我的 Silverlight 应用程序中进行调用,但是当我尝试修改项目以使用模拟时:
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
它在host.Open(); 期间抛出了一个异常:
System.InvalidOperationException 是 未处理的消息=合同 操作“GetData”需要 Windows 自动模仿的身份。 一个 Windows 标识,代表 调用者不是由绑定提供的 ('CustomBinding','http://tempuri.org/') 对于合同 ('IService1','http://tempuri.org/'.
这是我的配置:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="binaryHttpBinding">
<binaryMessageEncoding/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<services>
<service name="SLServiceLibrary.Service1" behaviorConfiguration="SLServiceLibrary.ServiceBehavior">
<endpoint address="Service1" binding="customBinding" contract="SLServiceLibrary.IService1" bindingConfiguration="binaryHttpBinding"/>
<endpoint address="" binding="webHttpBinding" contract="SLServiceLibrary.IClientAccessPolicy" behaviorConfiguration="webHttpEnablingBehavior"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SLServiceLibrary.ServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpEnablingBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
我必须进行哪些更改才能使其正常工作?我还需要为我的 Silverlight 客户端添加一些配置吗?
提前致谢:)
【问题讨论】:
标签: c# silverlight wcf impersonation