使用多个服务的WCF客户端
我试图弄清楚如何设置我的web.config(客户端)来使用两个不同的WCF web服务,一个使用另一个使用 我有两个端点,我想我需要两种不同的绑定配置。这是我当前的绑定节点:使用多个服务的WCF客户端,wcf,basichttpbinding,Wcf,Basichttpbinding,我试图弄清楚如何设置我的web.config(客户端)来使用两个不同的WCF web服务,一个使用另一个使用 我有两个端点,我想我需要两种不同的绑定配置。这是我当前的绑定节点: <basicHttpBinding> <binding name="WebServiceProxyServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00
<basicHttpBinding>
<binding name="WebServiceProxyServiceSoapBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
我无法添加其他basicHttpBinding节点。问题是,如果我只更改了
中的mode参数,那么绑定对于一个或另一个端点将非常有效
这似乎是一个常见的问题,但尚未找到答案。总的来说,除了简单的消费和通话之外,我对WCF(如果这不明显的话)的体验不太清楚。任何帮助都会很好
这篇文章很接近,但不是完全相同的问题,因为他们不需要不同的安全模式
提前感谢。您只需在
节点下添加另一个
节点,该节点具有不同的名称和任何您喜欢的不同选项
然后,很明显,只需通过在每个
节点的bindingConfiguration
属性中设置适当的名称,确保每个客户端都配置为使用特定于它们的绑定
我有两个端点,我想我
需要两个不同的绑定
配置。这是我现在的工作
绑定节点:
<basicHttpBinding>
<binding name="WebServiceProxyServiceSoapBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
不一定-如果这两个服务使用相同的设置和相同的协议,一个绑定配置就可以了
您需要添加两个客户端元素:
<system.serviceModel>
<bindings>
..... (as you already have it) ....
</bindings>
<client>
<endpoint name="Service1Endpoint"
address="http://yourserver/service1.svc"
binding="basicHttpBinding"
bindingConfiguration="WebServiceProxyServiceSoapBinding"
contract="IWCFService1" />
<endpoint name="Service2Endpoint"
address="http://yourserver/service2.svc"
binding="basicHttpBinding"
bindingConfiguration="WebServiceProxyServiceSoapBinding"
contract="IWCFService2" />
</client>
</system.serviceModel>
..... (因为你已经有了它)。。。。
这样就可以了
当然,如果您的第二个服务使用另一个绑定,或者需要不同的安全设置,那么是的,您需要在
节点下添加第二个
,并在此处从两个客户端端点之一引用第二个绑定配置。:)这太简单了。非常感谢。哦,我明白了,我在尝试添加第二个节点,而不是第二个子绑定节点!非常感谢。