WCF服务客户端 - 在开发与生产之间切换 - 最佳实践(部署)

Sex*_*yMF 2 wcf production-environment

我有一个带有WCF客户端的开发机器,现在开发完成
我想切换到生产,
所以我得到了生产服务器的WSDL链接(相同的服务,不同的链接)

为了切换到生产,我需要在Web配置版本中进行哪些更改?

谢谢

编辑
还有一件事,当我导入开发WSDL时,我在配置中得到了这个,我如何为生产创建一个?

<identity>
   <certificate encodedValue="AwAAAAEAAAAUAAAAiMP2hRL597Js3Czdjo....." />
</identity>
Run Code Online (Sandbox Code Playgroud)

Pau*_*mke 5

要找到prod WSDL和DEV WSDL之间的区别,您需要使用svcutil.

打开visual studio命令提示符,然后运行:

svcutil http://prod/service.svc

它会给你一个"output.config"的位置.打开它,看看差异.

部署的最佳实践是使用Microsoft在Visual Studio 2010中内置的Web.Config转换.详细信息:http://msdn.microsoft.com/en-us/library/dd465318.aspx

基本步骤是:

  1. 创建web.debug.config,web.release.config
  2. 确保您的构建配置设置说"发布".
  3. 使用上面链接中的替换语法编辑带有更改的"web.release.config".您可以替换原始web.config中的任何节点.
  4. 使用单击发布部署网站或创建部署包.

以下是替换端点配置区域的web.release.config示例.注意xdt:Transform ="Replace",它取代了整个客户端节点.

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <system.serviceModel>
        <client xdt:Transform="Replace">
            <endpoint address="http://prod/service.svc/binary" binding="customBinding"  behaviorConfiguration="LargeGraphBehavior"
                bindingConfiguration="BinaryHttpBinding" contract="CustomerService.ICustomer"
                name="BasicHttpBinding_ICustomer">
               <identity>
                   <certificate encodedValue="AwAAAAEAAAAUAAAAiMP2hRL597Js3Czdjo....." />
               </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)