我有一个服务器,它承载了3个web服务。
接口/签名将始终保持不变。
我也有adesktop应用程序。
当这个桌面应用程序注册到我的服务器时,它将返回一个IP地址,用于连接到web服务。
这里的想法是,我可以多个代理服务器,前50个客户机将分配server#1的ip地址和接下来的50 server#2等等。
为了使这一工作有效,我必须‘在我的客户端绑定中加倍服务的名称-我想知道为什么?
如果我们只关注1服务,这是服务器上的接口文件:
[ServiceContract]
public interface ISync
{
[OperationContract(IsOneWay = true)]
void UploadMotion(byte[] jpegStream, string alias, Int16 camIndex, byte[] motionLog);
}在服务器上的web.config中,这方面的绑定是:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ThrottledBehavior">
<serviceTimeouts transactionTimeout="0.00:00:30" />
<serviceThrottling maxConcurrentCalls="64" maxConcurrentSessions="50" maxConcurrentInstances="1" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Sync" behaviorConfiguration="ThrottledBehavior">
<endpoint address="Sync.svc" binding="basicHttpBinding" bindingConfiguration="ThrottledHttpBindingEndPoint" contract="ISync" name="wsSyncerMotion" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="ThrottledHttpBindingEndPoint" messageEncoding="Mtom" receiveTimeout="00:00:01" sendTimeout="00:00:01" transferMode="Streamed" closeTimeout="00:02:00" openTimeout="00:02:00">
<readerQuotas maxArrayLength="32768" />
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>在我的客户端桌面应用程序中,我的app.config文件中有以下绑定:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wsSyncerMotion" messageEncoding="Mtom" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.a url.co.uk/Sync.svc/Sync.svc"
binding="basicHttpBinding" bindingConfiguration="wsSyncerMotion"
contract="wsSyncer.ISync" name="wsSyncerMotion" />
</client>
</system.serviceModel>以及动态分配地址的c#代码:
ChannelFactory<HomeEdition.wsSyncer.ISyncChannel> FactorySync = null;
HomeEdition.wsSyncer.ISyncChannel UpLoadSync = null;
EndpointAddress addressSync = new EndpointAddress('a new ip address' + "/sync.svc/sync.svc");
FactorySync = new ChannelFactory<HomeEdition.wsSyncer.ISyncChannel>("wsSyncerMotion", addressSync);
UpLoadSync = Shared.FactorySync.CreateChannel();
UpLoadSync.OperationTimeout = new TimeSpan(0, 0, 0, 0, 1000);请注意以下内容:
sync.svc/sync.svc如果我把它简化为sync.svc,它就不起作用了。
我看不出该怎么做.
发布于 2014-04-18 12:48:20
只需更改端点地址:替换
<endpoint address="Sync.svc" binding="basicHttpBinding" bindingConfiguration="ThrottledHttpBindingEndPoint" contract="ISync" name="wsSyncerMotion" />通过
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="ThrottledHttpBindingEndPoint" contract="ISync" name="wsSyncerMotion" />和
<endpoint address="http://www.a url.co.uk/Sync.svc/Sync.svc"
binding="basicHttpBinding" bindingConfiguration="wsSyncerMotion"
contract="wsSyncer.ISync" name="wsSyncerMotion" />通过
<endpoint address="http://www.a url.co.uk/Sync.svc"
binding="basicHttpBinding" bindingConfiguration="wsSyncerMotion"
contract="wsSyncer.ISync" name="wsSyncerMotion" />当您想要通过几个绑定公开相同的服务时,WCF服务的基本URL的扩展非常有用。
https://stackoverflow.com/questions/23150577
复制相似问题