Search code examples
c#wcfwebservice-clientservice-referencewcf-endpoint

How to get the correct ServiceReference and its endpoint-address for a WCF-Webservice on installation


I'm facing a problem going into the installation of a project of mine. It consists of three parts, a clientside WindowsForms-application, a WCF-Webservice and a Database (SQLExpress atm).

At the moment, the endpoint-address and service-reference needed for the connection between Client and Webservice are hardcoded into the app.config of the WindowsForms-Project, referencing the specific computer in the same network the Webservice is running on like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IWemosService" maxBufferPoolSize="2147483647"
                maxReceivedMessageSize="2147483647" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://ent-ga-04:8733/Design_Time_Addresses/WcfServiceWemos/WemosService/"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWemosService"
            contract="ServiceReferenceWemos.IWemosService" name="BasicHttpBinding_IWemosService" />
    </client>
</system.serviceModel>
</configuration>

However, after installing client and Webservice on different devices, I'll have to change these values, of course, to match the new devices and connections. I just have no clue how to do so. Can you help me?


Solution

  • Okay, I found the answer by myself. Every C#-project comes with an appconfig, which, in the final version, is named [projectname].exe.config. The text inside is formatted like xml, so you can read, write and change its content. This way, you can change the endpoint, referencename etc.