Publishing a WCF Server and client and their endpoints

Posted by Ahmadreza on Stack Overflow See other posts from Stack Overflow or by Ahmadreza
Published on 2010-02-07T10:26:46Z Indexed on 2010/05/08 19:08 UTC
Read the original article Hit count: 298

Imagine developing a WCF solution with two projects (WCF Service/ and web application as WCF Client). As long as I'm developing these two projects in visual studio and referencing service to client (Web Application) as server reference there is no problem. Visual studio automatically assign a port for WCF server and configure all needed configuration including Server And Client binging to something like this in server:

   <service behaviorConfiguration="DefaultServiceBehavior"
    name="MYWCFProject.MyService">
    <endpoint address="" binding="wsHttpBinding" contract="MYWCFProject.IMyService">
     <identity>
      <dns value="localhost" />
     </identity>
    </endpoint>
    <host>
     <baseAddresses>
      <add baseAddress="http://localhost:8731/MyService.svc" />
     </baseAddresses>
    </host>
   </service>

and in client:

<client>
   <endpoint address="http://localhost:8731/MyService.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
    contract="MyWCFProject.IMyService"
    name="WSHttpBinding_IMyService">
    <identity>
     <dns value="localhost" />
    </identity>
   </endpoint>
  </client>

The problem is I want to frequently publish this two project in two different servers as my production servers and Service url will be "http://mywcfdomain/MyService.svc". I don't want to change config file every time I publish my server project. The question is: is there any feature in Visual Studio 2008 to automatically change the URLs or I have to define two different endpoints and I set them within my code (based on a parameter in my configuration for example Development/Published).

© Stack Overflow or respective owner

Related posts about wcf

Related posts about visual-studio