title: XElement not declared when using Service Reference Proxy with XmlAnyElementAttribute
body: <p>I am working on a Windows Phone 7 app that talks to a 3rd party Soap service. I used <code>Add Service Reference</code> to the wsdl to generate the proxy class. Some calls work, but certain outbound calls that make use of an '<code>sObject</code>' class result in the error <code>"The type System.Xml.Linq.XElement was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically"</code></p>
  
  <p>The relevant part of the sObject class is defined (as autogenerated)</p>
  
  <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:sobject.partner.soap.sforce.com")]
   public partial class sObject : object, System.ComponentModel.INotifyPropertyChanged {
  
      &lt;snipped ....&gt;
  
      [System.Xml.Serialization.XmlAnyElementAttribute(Namespace="urn:sobject.partner.soap.sforce.com", Order=3)]
      public System.Xml.Linq.XElement[] Any {
          get {
              return this.anyField;
          }
          set {
              this.anyField = value;
              this.RaisePropertyChanged("Any");
          }
      }
  </code></pre>
  
  <p>The code I use to create a sObject:</p>
  
  <pre><code>sObject post = new sObject();
          XElement postEls = new XElement("sObject",
              new XElement("Type", "TextPost"),
              new XElement("ParentId", userInfo.userId),
              new XElement("Body", postBody)
              );
  
          post.Any = postEls.Elements().ToArray();
  </code></pre>
  
  <p><strong>Steps I Have Tried:</strong></p>
  
  <p>Adding   <code>[System.Xml.Serialization.XmlInclude(typeof(System.Xml.Linq.XElement))]</code> to the sObject class.  Same error, it seems like this should have worked.</p>
  
  <p>Adding <code>[System.Xml.Serialization.XmlElement()]</code> to the Any property.  When I did this the message was serialized, but -as expected- incorrect (the Any elements should not be there, the goal is just the XElements[] as output)</p>
  
  <pre><code> &lt;sObject&gt;
        &lt;type xmlns="urn:sobject.partner.soap.sforce.com"&gt;FeedPost&lt;/type&gt;
        &lt;Id xsi:nil="true" xmlns="urn:sobject.partner.soap.sforce.com" /&gt;
        &lt;Any xmlns="urn:sobject.partner.soap.sforce.com"&gt;
          &lt;Type xmlns=""&gt;TextPost&lt;/Type&gt;
        &lt;/Any&gt;
        &lt;Any xmlns="urn:sobject.partner.soap.sforce.com"&gt;
          &lt;ParentId xmlns=""&gt;XXXXXX&lt;/ParentId&gt;
        &lt;/Any&gt;
        &lt;Any xmlns="urn:sobject.partner.soap.sforce.com"&gt;
          &lt;Body xmlns=""&gt;Test post from WP7!&lt;/Body&gt;
        &lt;/Any&gt;
      &lt;/sObject&gt;
  </code></pre>
  
  <p>As an aside, I suspect this is related, calls that return sObjects inbound from the 3rd party service have their Any property null, despite the data being there in the RPC Response.</p>