title: How to send XML within a SOAP message
body: <p>I'm trying to guide a colleague towards the most correct way of sending an XML document in a SOAP message, but I'm no expert on the subject. It seems like something that should be solvable using a CDATA section, but a default gSOAP serializer is 'helping' by encoding all '&lt;' and '>'.</p>
  
  <p>For example, when we try to send this:</p>
  
  <pre><code>&lt;xml&gt;
      &lt;tag&gt;
          &lt;content&gt;
              &lt;![CDATA[&lt;xml&gt;&lt;tag&gt;Text!&lt;/tag&gt;&lt;/xml&gt;]]&gt;
          &lt;/content&gt;
      &lt;/tag&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p>What actually gets sent is more like this:</p>
  
  <pre><code>&lt;xml&gt;
      &lt;tag&gt;
          &lt;content&gt;
              &amp;lt;![CDATA[&amp;lt;xml&amp;gt;&amp;lt;tag&amp;gt;Text!&amp;lt;/tag&amp;gt;&amp;lt;/xml&amp;gt;]]&amp;gt;
          &lt;/content&gt;
      &lt;/tag&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p><em>If</em> the receiver was also gSOAP based we may transparently get away with that without even needing the CDATA markers, but that is not the case. The receiver is some PHP code, so using html_entity_decode may work, but it feels wrong (and perhaps wouldn't work in all cases?).</p>
  
  <p>I was hoping/expecting the solution would be to specify a different type for the field (currently 'xsd:string') so that a dumber serializer got used, preserving the CDATA markers and the content within.</p>
  
  <p>I'd like to avoid any in-house wheel-reinvention if there's a simple and correct way to solve this (base64 encoding the payload is being proposed).</p>