title: How can I set attributes for SOAP elements in Delphi?
body: <p>In a SOAP client request, the header needs this line:</p>
  
  <pre><code>&lt;NS2:Header Name="Foo"&gt;Bar&lt;NS2:Header&gt;
  </code></pre>
  
  <p>So I wrote a class which has two string properties: </p>
  
  <ul>
  <li>the Content property - for the value of the element ("Bar")</li>
  <li>the Name property - for the value of the attribute ("Foo")</li>
  </ul>
  
  <p>The AS_ATTRIBUTE flag of the Name property should indicate that it is an XML "attribute".</p>
  
  <pre><code>   Header = class(TSoapHeader)
     private
       FContent: string;
       FName: string;
     published
       property Content: string read FContent write FContent;
       property Name: string read FName write FName stored AS_ATTRIBUTE;
     end;
  </code></pre>
  
  <p>and register with</p>
  
  <pre><code>   RemClassRegistry.RegisterXSClass(Header, MY_URI);
     RemClassRegistry.RegisterSerializeOptions(Header, [xoLiteralParam, 
  xoSimpleTypeWrapper]);
  </code></pre>
  
  <p>The xoLiteralTypWrapper option indicates that the class should only 'wrap' the value Content property in the  element and not add a nested  element for it.</p>
  
  <p>For Name := "Foo" and Content := "Bar", this will be the result XML code in the SOAP request:</p>
  
  <pre><code>&lt;NS2:Header Name="Foo"&gt;
     &lt;Content xsi:type="xsd:string"&gt;Bar&lt;/Content&gt;
  &lt;/NS2:Header&gt;
  </code></pre>
  
  <p>The attribute is in the correct place, but the content value is in a nested tag which should not be here. If I remove the Name property from the class definition the Content property will look nice as the element content, like this:</p>
  
  <pre><code>&lt;NS2:Header&gt;Bar&lt;/NS2:Header&gt;
  </code></pre>
  
  <p>It looks like a conflict between the two requirements - if I have the 
  attribute, I will not get the xoSimpleTypeWrapper style.</p>