想象一下开发具有两个项目(WCF服务/和Web应用程序作为WCF客户端)的WCF解决方案。只要我在Visual Studio中开发这两个项目并将服务引用到客户端(Web应用程序)作为服务器参考,就没有问题。 Visual Studio的自动分配WCF服务器的端口,并配置包括服务器和客户端暴食到这样的事情在服务器的所有需要的配置:发布WCF服务器和客户端及其端点
<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>
,并在客户端:
<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>
的问题是我想经常在两台不同的服务器上发布这两个项目,因为我的生产服务器和服务URL将为“http://mywcfdomain/MyService.svc”。每次我发布我的服务器项目时,我都不想更改配置文件。 问题是:Visual Studio 2008中是否有自动更改URL的功能,或者我必须定义两个不同的端点,并将其设置在我的代码中(基于我的配置中的一个参数,例如Development/Published)。