【发布时间】:2011-07-06 06:48:21
【问题描述】:
我的第一个 WCF 示例正在运行。我在一个有很多绑定的网站上有主机。因此,我已将此添加到我的 web.config 中。
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
这是我的默认绑定http://id.web,它适用于以下代码。
EchoServiceClient client = new EchoServiceClient();
litResponse.Text = client.SendEcho("Hello World");
client.Close();
我现在尝试在运行时设置端点地址。即使是上面代码的同一个地址。
EchoServiceClient client = new EchoServiceClient();
client.Endpoint.Address = new EndpointAddress("http://id.web/Services/EchoService.svc");
litResponse.Text = client.SendEcho("Hello World");
client.Close();
我得到的错误是:
The request for security token could not be satisfied because authentication failed.
请建议我如何在运行时更改端点地址?
这是我的客户端配置,应 Ladislav Mrnka 的要求
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IEchoService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://id.web/Services/EchoService.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IEchoService" contract="IEchoService"
name="WSHttpBinding_IEchoService">
<identity>
<servicePrincipalName value="host/mikev-ws" />
</identity>
</endpoint>
</client>
</system.serviceModel>
【问题讨论】:
-
您的客户端配置如何?
-
@Ladislav Mrnka:我已经更新了我的帖子以显示客户端配置。谢谢
标签: c# wcf wcf-binding wcf-client