title: CData and Escape characters in a C# Webservice Reference
body: <p>I am trying to communicate with some thirdparty middleware Java webservice,
  We send an XML over Soap using a string, which causes the automagically generated visual bindings to replace some characters with escape characters </p>
  
  <pre><code>"&amp;lt;" / "&amp;gt;" / "&amp;#xD;" 
  </code></pre>
  
  <p>that for some reason the Java Webservice (soap host) can't deal with.</p>
  
  <p>So the alternative to escaping illegal characters is wrapping everything in an </p>
  
  <pre><code>"&lt;![CDATA[...]]", 
  </code></pre>
  
  <p>however this doesn't stop the automatically generated bindings from escaping all special     </p>
  
  <pre><code>(&lt;, &gt;, \) 
  </code></pre>
  
  <p>characters.</p>
  
  <p>So the result is something like this</p>
  
  <p><a href="https://i.stack.imgur.com/w5xkD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w5xkD.png" alt="enter image description here"></a></p>
  
  <p>Does anyone have any suggestions how to approach this problem?</p>
  
  <pre><code>EndpointAddress = New System.ServiceModel.EndpointAddress(WebserviceReleaseURL)
  serviceBinding = New System.ServiceModel.BasicHttpBinding()
  serviceBinding.ReceiveTimeout = New TimeSpan(0, 0, 120)
  
  serviceBinding.Security.Mode = BasicHttpSecurityMode.Transport
  serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic
  
  serviceBinding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Mtom
  
  serviceBinding.ProxyAddress = New Uri("http://127.0.0.1:8888")
  serviceBinding.BypassProxyOnLocal = False
  serviceBinding.UseDefaultWebProxy = False
  
  c = New VU.receive_PortTypeClient(serviceBinding, endpointAddress)
  
  c.ClientCredentials.UserName.UserName = WebserviceReleaseUsername
  c.ClientCredentials.UserName.Password = WebserviceReleasePassword
  c.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
  
  c.Open()
  
  Dim ServiceInput As New VU.receiveIn
  Dim ServiceOutput As New VU.receiveOut
  
  Dim cdata As New XCData(data)
  
  ServiceInput.xmlString = cdata.ToString();
  ServiceOutput = c.receive(ServiceInput)
  </code></pre>