我处于这样一种情况,我只想更新WCF端点的URL的一部分.现在,我们通过在每个"种类"中包含所有端点的不同配置来实现此目的.这很难管理.我想在web.config中设置一个转换来实现.
这些是文件的两个示例
开发
<endpoint address="http://servicesdev.host.com/RPUtilityServices/LogException.svc/restService"
behaviorConfiguration="restfulBehavior"
binding="webHttpBinding"
contract="Host.RP.Shared.Common.Services.Utility.Interfaces.IExceptionUtilityService"
name="LogService" />
Run Code Online (Sandbox Code Playgroud)
还有一些这些
分期
<endpoint address="http://servicessta.host.com/RPUtilityServices/LogException.svc/restService"
behaviorConfiguration="restfulBehavior"
binding="webHttpBinding"
contract="Host.RP.Shared.Common.Services.Utility.Interfaces.IExceptionUtilityService"
name="LogService" />
Run Code Online (Sandbox Code Playgroud)
不同之处在于servicessta与servicesdev.现在我也有serviceuat和servicesqa etcera.我想设置一个转换,只是将' dev ' 替换为' sta '等而不是整个块(使用xdt:Transform="Replace")
但是我该怎么做?
c# web-config .net-4.5 visual-studio-2012 web.config-transform
我有一个引用了很多WCF服务的C#项目.对于本地测试,我想替换身份标记的内容,以便它接受在localhost上运行的任何内容.
以下转换有效,但仅在第一个匹配位置插入dns元素.因此,如果我引用了5个端点,则会有一个dns标记,而其他端点都会有空的标识元素.
<system.serviceModel>
<client>
<endpoint>
<identity>
<dns xdt:Transform="Insert" value="localhost"/>
<userPrincipalName xdt:Transform="RemoveAll" value="someIdentity" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
如何更改所有匹配元素,而不仅仅是第一个?
我正在尝试删除Web.Release.config文件中的所有服务端点mexHttpBinding节点.我找到了这个答案 :(
我从我的代码文件中复制了,所以它实际上的格式与答案不同)
<services>
<service>
<endpoint binding="mexHttpBinding"
xdt:Locator="Match(binding)"
xdt:Transform="RemoveAll" />
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
我收到
的警告是在<service>节点上:
缺少必需的属性"名称".
我是否需要在节点的属性中添加空字符串或通配符(如果有)以解决此警告?
此外,上述转换不应该包含在节点中,还是不包含?name<service><system.serviceModel>
asp.net web-config-transform xml-document-transform web-release-config web-debug-config