Note that there are some explanatory texts on larger screens.

plurals
  1. POXmlSerializer Serialize empty variable to use both tags?
    primarykey
    data
    text
    <p>I want to be able to load a serialized xml class to a Soap Envelope. I am starting so I am not filling the innards so it appears like: <br /> </p> <pre><code>&lt;Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" /&gt; </code></pre> <p>I want it to appear like: <br/></p> <pre><code>&lt;Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" &gt;&lt;/Envelope&gt;` </code></pre> <p><br /></p> <p>The class I wrote is this: <br/></p> <pre><code>[System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")] [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.xmlsoap.org/soap/envelope/",ElementName="Envelope", IsNullable = true)] public class TestXmlEnvelope { [System.Xml.Serialization.XmlElement(ElementName="Body", Namespace="http://schemas.xmlsoap.org/soap/envelope/")] public System.Collections.ArrayList Body = new System.Collections.ArrayList(); } //class TestXmlEnvelope` </code></pre> <p>I am using this as an example since other people might want it in an individual element. I am sure this must be simple but sadly I don't know the right keyword for this.</p> <p>As always thanks for your help.</p> <p>[Edit] The error comes when I try to use this instruction</p> <pre><code>System.Xml.Serialization.XmlSerializer xmlout = new System.Xml.Serialization.XmlSerializer(typeof(TestXmlEnvelope)); System.IO.MemoryStream memOut = new System.IO.MemoryStream(); xmlout.Serialize(memOut, envelope, namespc); Microsoft.Web.Services.SoapEnvelope soapEnv = new Microsoft.Web.Services.SoapEnvelope(); soapEnv.Load(memOut); </code></pre> <p>It gives me error "Root Element not found". </p> <p>[Edit] I fixed the error the problem was that after I serialized the object I didn't set the memOut.Position = 0. Still I hope this question helps other people that may want to do this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload