views:

342

answers:

2

I’ve just created a WCF service/client and it all works fine when running on the same machine. But can’t figure out how to configure it to run on different machines. Do you know how?

At the moment the URI is set to http://localHost:8000......

But I think I want something like net.tcp://MyServer:8000…..

Any ideas would be great. Thanks.

A: 

There isn't enough information here to answer your question.

Assuming you aren't setting address/binding/contract information in the ServiceHost and proxies through code, you need to post the section of your config file.

If you are doing it in code, then you need to show what code you are using.

From what I can tell, it seems that you might have a mismatch with the transport binding. The service and the client have to be on the same transport (http, tcp, named pipes, etc, etc).

casperOne
+1  A: 

From what it sounds like, you have both the service and client in the same executable. While this can be done, when you want them on separate machines you need to have an executable/host for the service (either self hosted, or in IIS) and an executable for the client. Each will need to be properly configured with the address, binding, and contract in the appropriate configuration section for it. So on the server you'd have something like this:

<configuration>
    <system.serviceModel>
        <services>
            <service name="YourService">
                <endpoint address="http://MyServer:8000/..."
                          binding="BasicHttpBinding"
                          contract="Your.IContract" />
            </service>
        </services>
    </system.serviceModel>
</configuration>

And on the client you'd have this:

<configuration>
    <system.serviceModel>
        <client>
            <endpoint address="http://MyServer:8000/..."
                      binding="BasicHttpBinding"
                      contract="Your.IContract"
                      name="ClientEndpoint" />
        </client>
    </system.serviceModel>
</configuration>

The main thing is to make sure that the client and server can communicate with each other over the specified port and protocol (primarily making sure a firewall isn't blocking communication). The other thing to be aware of is changing your binding protocol may impact other aspects of your service (security is a big one, but also what you can and cannot do with the service).

Agent_9191