Question

I have a server which hosts 3 web services.

The interface/signature will always remain the same.

I also have adesktop application.

When this desktop application registers itself to my server it will given back an IP address to use to connect to the web service.

The idea here is that I could multiple dedciated servers and the 1st 50 clients will ber assigned the ip address of server#1 and the the next 50 server#2 and so on.

To get this to work I had to 'double up the name of the service in my client bindings and I want to know why is that?

If we just concentrate on 1 service this is the interface file on the server for it:

[ServiceContract]
public interface ISync
{
    [OperationContract(IsOneWay = true)]
    void UploadMotion(byte[] jpegStream, string alias, Int16 camIndex, byte[] motionLog);
}

the bindings for this in my web.config on the server is:

  <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>

In my Client Desktop app I have these bindings in my app.config file:

  <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>

And my c# code to dynamically allocate an address:

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);

notice this:

sync.svc/sync.svc

If I reduce it to just sync.svc it does not work.

I cannot see logically what to do...

Was it helpful?

Solution

Just change your endpoint address : replace

<endpoint address="Sync.svc" binding="basicHttpBinding" bindingConfiguration="ThrottledHttpBindingEndPoint" contract="ISync" name="wsSyncerMotion" />

by

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="ThrottledHttpBindingEndPoint" contract="ISync" name="wsSyncerMotion" />

and

  <endpoint address="http://www.a url.co.uk/Sync.svc/Sync.svc"
    binding="basicHttpBinding" bindingConfiguration="wsSyncerMotion"
    contract="wsSyncer.ISync" name="wsSyncerMotion" />

by

  <endpoint address="http://www.a url.co.uk/Sync.svc"
    binding="basicHttpBinding" bindingConfiguration="wsSyncerMotion"
    contract="wsSyncer.ISync" name="wsSyncerMotion" />

The extension to the base URL of a WCF service is useful when you want to expose the same service via several bindings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top