慢速猎豹没有在app.config中转换端点标签

时间:2012-08-27 19:41:32

标签: wcf windows-services app-config slowcheetah

我喜欢SlowCheetah,但它在app.config中转换端点时遇到了一些问题。我希望也许有人可以看看我错过了什么,或者过去曾经遇到过这个问题。

app.config默认

  <connectionStrings>

    <add name="MyEntities" connectionString="metadata=res://*/RFPModel.csdl|res://*/RFPModel.ssdl|res://*/RFPModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=developmentServer;initial catalog=databaseName;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IMasterEngineService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://DevelopmentServer/WebServices/MasterEngine/MasterEngineService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService" contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService" />
    </client>
  </system.serviceModel>

</configuration>

Release for Release是:

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/RFPModel.csdl|res://*/RFPModel.ssdl|res://*/RFPModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=releaseServer;initial catalog=databaseName;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"  xdt:Transform="Replace" xdt:Locator="Match(name)" />
  </connectionStrings>

  <endpoint address="http://productionServer/WebServices/MasterEngine/MasterEngineService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService" contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService"  xdt:Transform="Replace" xdt:Locator="Match(name)">
  </endpoint>

</configuration>

我正常,创建配置并确保在构建之前我处于正确的配置/环境中,但无论我做什么,即使选择Release环境/配置,它仍保持相同的开发服务器。

有什么想法吗?

- 更新 - 每次请求,尝试:

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.serviceModel>
    <client>
      <endpoint address="http://productionServer/WebServices/MasterEngine/MasterEngineService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService" contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService"  xdt:Transform="Replace" xdt:Locator="Match(name)" />
    </client>
  </system.serviceModel>

  <connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/RFPModel.csdl|res://*/RFPModel.ssdl|res://*/RFPModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=databaseName;initial catalog=dash;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"  xdt:Transform="Replace" xdt:Locator="Match(name)" />
  </connectionStrings>

</configuration>

没用?

-UPDATE AGAIN ---

首先尝试了你对connectionString的建议......无济于事

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">


  <connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/RFPModel.csdl|res://*/RFPModel.ssdl|res://*/RFPModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=databaseName;initial catalog=dash;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"  xdt:Transform="Replace" xdt:Locator="Match(name)" />
  </connectionStrings>

  <client>
      <endpoint address="productionServerName/WebServices/MasterEngine/MasterEngineService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService" contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService"  xdt:Transform="Replace" xdt:Locator="Match(name)" />
    </client>


</configuration>

2 个答案:

答案 0 :(得分:6)

在我的第一条评论中提出建议后,这对我有用:

它应该是system.serviceModel / client / endpoint,而不是配置/端点。

的Web.config

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->

<configuration>
  <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>

  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

    <authentication mode="Windows">

    </authentication>

    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IMasterEngineService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://DevelopmentServer/WebServices/MasterEngine/MasterEngineService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService" contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService" />
    </client>
  </system.serviceModel>

</configuration>

Web.Debug.config

<?xml version="1.0"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <!--
    In the example below, the "SetAttributes" transform will change the value of 
    "connectionString" to use "ReleaseSQLServer" only when the "Match" locator 
    finds an atrribute "name" that has a value of "MyDB".

    <connectionStrings>
      <add name="MyDB" 
        connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 
        xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>
  -->
  <system.web>
    <!--
      In the example below, the "Replace" transform will replace the entire 
      <customErrors> section of your web.config file.
      Note that because there is only one customErrors section under the 
      <system.web> node, there is no need to use the "xdt:Locator" attribute.

      <customErrors defaultRedirect="GenericError.htm"
        mode="RemoteOnly" xdt:Transform="Replace">
        <error statusCode="500" redirect="InternalError.htm"/>
      </customErrors>
    -->
  </system.web>


  <system.serviceModel>
    <client>
      <endpoint address="http://productionServer/WebServices/MasterEngine/MasterEngineService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService" contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService"  xdt:Transform="Replace" xdt:Locator="Match(name)" />
    </client>
  </system.serviceModel>

</configuration>

和预览转换比较窗口:

transformation compare

答案 1 :(得分:4)

尝试SetAttributes转换:

 <system.serviceModel>       
        <client>           
            <endpoint name="BasicHttpBinding_IMasterEngineService"
address="http://productionServer/WebServices/MasterEngine/MasterEngineService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService"
contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService"
xdt:Transform="SetAttributes(address)" xdt:Locator="Match(name)"/>
        </client>
    </system.serviceModel>

您可以使用逗号分隔的属性值,您需要更改这些值。 虽然只有不好的例子,但希望this链接会有所帮助。