Web services 不同环境的配置文件中的WCF端点信息

Web services 不同环境的配置文件中的WCF端点信息,web-services,wcf,web.config-transform,Web Services,Wcf,Web.config Transform,我想知道在不同环境(开发、测试、预生产、生产)的配置文件中保存WCF端点信息的最佳方法是什么 我熟悉这样做的一种方法-1。维护不同的配置文件(针对每个环境)并相应地部署它们 有人可以建议最好的方法吗???您可以在运行时使用EndpointBehavior配置端点。在这种行为中,您可以获得machinename。根据machinename,您可以为端点设置endpointaddress,然后启动服务。 以下是一个链接: 编辑: 所以你写: class CustomEndpointBehavior

我想知道在不同环境(开发、测试、预生产、生产)的配置文件中保存WCF端点信息的最佳方法是什么

我熟悉这样做的一种方法-1。维护不同的配置文件(针对每个环境)并相应地部署它们


有人可以建议最好的方法吗???

您可以在运行时使用EndpointBehavior配置端点。在这种行为中,您可以获得machinename。根据machinename,您可以为端点设置endpointaddress,然后启动服务。 以下是一个链接:

编辑:

所以你写:

class CustomEndpointBehavior : IEndpointBehavior{
 public void Validate(ServiceEndpoint endpoint)
{
  // get here the address and rewrite it dependig on the machinemane e.g.
  // remember to set the new address to the endpoint!

}

public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{

}

public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{

}

public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{

}
}
在启动服务的类中,需要将CustomEndpointBehavior设置为serviceHost,如:

serviceHost.Description.Behaviors.Add(new CustomEndpointBehavior());

我想这就是联系。创建多个配置,然后使用预生成事件复制它

在VisualStudio2010及更高版本中,它将能够合并配置