Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3229420
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:48:31+00:00 2026-05-17T16:48:31+00:00

I am working on a Windows Phone 7 app that talks to a 3rd

  • 0

I am working on a Windows Phone 7 app that talks to a 3rd party Soap service. I used Add Service Reference to the wsdl to generate the proxy class. Some calls work, but certain outbound calls that make use of an ‘sObject‘ class result in the error "The type System.Xml.Linq.XElement was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically"

The relevant part of the sObject class is defined (as autogenerated)

[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 {

    <snipped ....>

    [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");
        }
    }

The code I use to create a sObject:

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();

Steps I Have Tried:

Adding [System.Xml.Serialization.XmlInclude(typeof(System.Xml.Linq.XElement))] to the sObject class. Same error, it seems like this should have worked.

Adding [System.Xml.Serialization.XmlElement()] 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)

 <sObject>
      <type xmlns="urn:sobject.partner.soap.sforce.com">FeedPost</type>
      <Id xsi:nil="true" xmlns="urn:sobject.partner.soap.sforce.com" />
      <Any xmlns="urn:sobject.partner.soap.sforce.com">
        <Type xmlns="">TextPost</Type>
      </Any>
      <Any xmlns="urn:sobject.partner.soap.sforce.com">
        <ParentId xmlns="">XXXXXX</ParentId>
      </Any>
      <Any xmlns="urn:sobject.partner.soap.sforce.com">
        <Body xmlns="">Test post from WP7!</Body>
      </Any>
    </sObject>

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:48:32+00:00Added an answer on May 17, 2026 at 4:48 pm

    It turns out the exception was due to the serialization of XElement[], currently an issue in Windows Phone 7.

    As noted by Vijay Verma here, The linked MSDN article on XmlSerializer.Serialize states under Platform Notes:

    Silverlight for Windows Phone:
    The XmlSerializer.Serialize method throws an InvalidOperationException if the XmlSerializer object is initialized with a type parameter that contains an array of objects of type XElement.

    Vijay listed a workaround of using a single XElement and parsing the field separately. This would work if you control both sides of the SOAP message. Unfortunately I do not so the request is invalid on the 3rd party’s side.

    This explains the InvalidOperationException with XElement was not expected, although not the answer I was hoping for. Hopefully it helps someone else who may have control over both sides of the service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Windows Phone 7 app that requires some data encryption. I'm
I am working on a Windows Phone 7 app and I want to give
I'm in lean startup mode, working on a simple phone app that will be
I've been working on a Windows Phone 7 app, and after a bit of
I'm working on a Windows Phone 7 app, and I was wondering whether anyone
Hi I am working in windows 7 phone based app using silverlight. I have
Hello there fellow developers! I am working on a Windows Phone 7 app and
I'm working on an app in C# (Windows-Phone-7), and I'm trying to do something
I'm working on a Windows Phone 7 app using WCF for communications with my
I am working on a Windows Phone 7 app, and trying to change some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.