views:

178

answers:

2

I'm trying to get my head around the addressing of WCF services.

We have a client-server setup where the server occasionally (maybe once a day) needs to push data to each client. I want to have a lightweight WCF listener service on each client hosted in an NT service to receive that data. We already have such an NT service setup hosting some local WCF services for other tasks so the overhead of this is minimal.

Because of existing legacy code on the server I believe the service needs to be exposed as ASMX and use basicHttpBinding to allow it to connect.

Each client is registered on the server by the user (they need to configure them individually) so discovery is not the issue.

My question is, how does the addressing work? I imagine the user entering the client's address on the server in the form

http://0.0.0.0/MyService

or even

http://hostname/MyService

If so, how do I configure the client service in its App.config? Do I use localhost?

If not then what is the reccommended way of exposing the service to the server?

Note:

  • I don't want to host in IIS as that adds extra requirements to the hardware required for the client.
  • The clients will be almost certainly located on LANs, not over the public internet
+1  A: 

You configure the base address of the service like so:

<system.serviceModel>
  <services>
    <service name="Ns.FooService">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:9999" />
        </baseAddresses>
      </host>
      <endpoint
          address="/foo"
          binding="basicHttpBinding"
          contract="Ns.IFooContract" />
     </service>
  </services>
</system.serviceModel>

And then your service could be accessible through http://servename:9999/foo. You may take a look at this article for more information.

Darin Dimitrov
Thanks Darin, that's exactly what I needed to know.
Mark Pim
A: 

As a sub-answer to my own question, I've found an MSDN article detailing how to expose ASMX out of IIS.

Mark Pim