我的WCF服务使用wsHttpBinding,当客户端使用默认选项对服务进行gerenated时,客户端可以正常工作,如下所示:
RServiceClient R = new RServiceClient();
Run Code Online (Sandbox Code Playgroud)
但是,在某些时候,我需要能够指定服务的位置,可能是通过更改端点地址,如下所示:
RServiceClient R = new RServiceClient();
R.Endpoint.Address = new EndpointAddress(new Uri "http://xxx.xxxx.xxx:80/RServer/RService.svc"));
Run Code Online (Sandbox Code Playgroud)
但是,当我确实指定了确切的端点时,我得到一个SecurityNegotiationException:System.ServiceModel.Security.SecurityNegotiationException未处理Message ="调用者未被服务验证." 来源= "mscorlib程序" ....
WCF服务在IIS上运行,并在IIS管理员下启用了匿名访问.此外,当客户端从与管理员帐户下的服务相同的计算机运行时,会发生此错误 - 我还没有到达通过网络运行它的可怕部分!
有任何想法吗?
默认情况下,wsHttpBinding使用Windows身份验证.我不确定IIS中的托管如何影响该场景.
如果您不想打开安全性,可以添加一个安全元素,并将模式元素设置为"无"到两端的配置以关闭默认设置.
我认为这可能有用 - 我已经为wsHttpBinding添加了部分,并将服务的bindingConfiguration设置为指向新添加的绑定属性:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBind">
<security mode="None">
<transport clientCredentialType="None" protectionLevel="EncryptAndSign" />
<message clientCredentialType="None" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior"
name="RService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttpBind"
name="RService"
contract="IRService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
name="MetadataExchange"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22848 次 |
| 最近记录: |