下面有一个配置文件示例。有许多可用的绑定,如
**basicHttpBinding,netTcpBinding,wsDualHttpBinding** basicHttpBinding,netTcpBinding,wsDualHttpBinding我是新加入WCF的,脑子里有很多困惑,这些是
那么,人们如何从客户端创建代理来连接wcf http://YourServer/Services/MyService/mex,他们都使用mex端点地址service.Naturally。
如果一个mex端点就足够了,那么客户端如何使用netTcpBinding或wsDualHttpBinding向客户端应用程序提供连接到wcf服务的指示。
请与我分享以下知识: 1)如果我使用客户端的mex端点地址创建代理,那么我的应用程序将使用哪些绑定连接到wcf服务?
2)如何使用、netTcpBinding或wsDualHttpBinding从客户端连接wcf服务?
寻找深度discussion.Thanks
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="YourNamespace.YourService" behaviorConfiguration="Default">
<endpoint name="Default"
address="http://YourServer/Services/MyService"
binding="basicHttpBinding"
contract="YourNamespace.IYourService"/>
<endpoint name="TCP"
address="net.tcp://YourServer/ServicesTCP/MyService"
binding="netTcpBinding"
contract="YourNamespace.IYourService"/>
<endpoint name="mex"
address="http://YourServer/Services/MyService/mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<endpoint name="Dual"
address="http://YourServer/Services/MyService/Dual"
binding="wsDualHttpBinding"
clientBaseAddress="http://localhost:8001/client/"
contract="YourNamespace.IYourDualService"/>
</service>
</services>
</system.serviceModel>发布于 2013-01-07 12:08:55
如果服务具有多个端点,则创建的代理包含服务上公开的每个契约类型的单独客户端类。如果您有多个具有相同约定的端点,则在客户端的配置文件中定义这些端点,并且每个端点都指定了一个名称。当您想用特定的绑定调用服务时,只需将端点配置的名称传递给代理构造函数。
发布于 2013-01-07 12:36:15
如何使用netTcpBinding或wsDualHttpBinding从客户端连接wcf服务--使用代码有什么诀窍吗?
这可以通过命名所有配置并将其中一个名称传递给clientproxy来实现:
public class SomeServiceClient : ClientBase<ISomeService>, ISomeService
{
public SomeServiceClient() { }
public SomeServiceClient(string endpointConfigurationName) :
base(endpointConfigurationName) { }
public void Do()
{
Channel.Do();
}
}这样,您可以更改端点(从而绑定)运行时。关于一个工作示例,请查看(https://www.box.com/shared/n4unt3mtjx) -- Peter (http://peterbernhardt.wordpress.com/2008/09/17/security-and-identity-in-wcf-part-4-authorizing-custom-claims/)的一个很好的实现
https://stackoverflow.com/questions/14174983
复制相似问题