Home > Blockchain >  Web.Config transformation - section with namespace not being transformed
Web.Config transformation - section with namespace not being transformed

Time:09-17

I have a web.config on an ASP.Net WCF .Net Framework 4.0, and I have transformations depending on the build environment.

The thing is that I have a diagnostics section inside my system.serviceModel section. On the base web.config this is empty:

<diagnostics></diagnostics>

Then on my transformation, we apply filters which contain namespaces, like this:

<diagnostics performanceCounters="All" xdt:Transform="Replace">
   <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="300000" maxSizeOfMessageToLog="200000000">
     <filters>
       <add xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">/s:Envelope/s:Header/a:Action[contains(.,'IMyService')]</add>
     </filters>
   </messageLogging>
 </diagnostics>

When the transformation is applied (xdt:Transform="Replace"), I get this:

<diagnostics performanceCounters="All">
 <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
 maxMessagesToLog="300000" maxSizeOfMessageToLog="200000000">
 <filters>
 <add>/s:Envelope/s:Header/a:Action[contains(.,'IMyService')]</add>
 </filters>
 </messageLogging>
 </diagnostics>

Which causes the web.config to have an Xml error, not working properly.

So the goal would be that after transforming, the namespace declaration would appear on every "add" element. I've tried declading the namespaces at configuration level but unsuccessfuly...

Resuming, this is the current output on the filter:

<add>/s:Envelope/s:Header/a:Action[contains(.,'IMyService')]</add>

And we would expect it to be like this:

<add xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">/s:Envelope/s:Header/a:Action[contains(.,'IMyService')]</add>

How can I overcome this?

CodePudding user response:

I was unable to find an appropriate solution, even declaring namespaces before was not working...

We ended up having instead of transformations, the whole web.config per environment then at release time the appropriate one is picked up and assumed as the right one.

  •  Tags:  
  • wcf
  • Related