How do I configure WCF service for clients running on networked computers?

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

The URI is currently set to http: // localHost: 8000 ......

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

Any ideas would be great. Thank.

0


source to share


2 answers


From what it sounds like, you have both 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 yourself or in IIS), or an executable for the client. Each one must be configured correctly with address, binding and contract in the appropriate configuration section for it. So, on the server, you will 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 will have the following:



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

      

The main thing is that the client and server can communicate with each other using the specified port and protocol (first of all, so that the firewall does not block communication). Another thing to be aware of is that changing the binding protocol can affect other aspects of your service (security is great, but also something you can and cannot do with the service).

+1


source


There is not enough information here to answer your question.

Assuming you are not setting the address / binding / contract information in the ServiceHost and proxy via code, you need to post a section of your config file.



If you do this in code, you need to show what code you are using.

From what I can tell, it seems like you might have a transport binding mismatch. Service and client must be on the same transport (http, tcp, named pipes, etc., etc.).

0


source







All Articles