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

  • SEARCH
  • Home
  • 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 1031269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:54:02+00:00 2026-05-16T13:54:02+00:00

It seems there is a known bug in wsdl.exe, the tool that Visual Studio

  • 0

It seems there is a known bug in wsdl.exe, the tool that Visual Studio uses to generate web service proxies. With certain XSD schemas the tool will generate classes that can’t be deserialized from the XML.

As far as I’m concerned that’s unacceptable, but I don’t know how to fix it.

I will describe my case in detail, hopefully somebody will be able to help me with it.

Schema

<!-- return type from the service operation -->
<xs:complexType name="listAssetsQueryResults">
    <xs:sequence>
        <xs:element name="assets" type="tns:asset" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

<!-- a sequence of attributes -->
<xs:complexType name="asset">
    <xs:sequence>
        <xs:element name="attributes" type="tns:multiValuedAttribute" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="multiValuedAttribute">
    <!-- not relevant-->
</xs:complexType>

XML response from the webservice

A typical response according to this schema looks like this:

<assets-query-result>
    <assets>
        <attributes>
            <name>Keywords</name>
            <values>Desert</values>
        </attributes>
        <attributes>
            <name>Filename</name>
            <values>Desert.jpg</values>
        </attributes>
    </assets>
    <assets>...</assets>
    <assets>...</assets>
</assets-query-result>

Using the types in code

I would have expected to be able to use the CLR types like this:

result.assets[0].attributes[0].name

Instead, the generated type for the result looks like this:

[SerializableAttribute()]
public partial class listAssetsQueryResults {
    private multiValuedAttribute[][] assetsField;

    [XmlArrayAttribute(Form=XmlSchemaForm.Unqualified, IsNullable=true)]
    [XmlArrayItemAttribute("attributes", typeof(multiValuedAttribute), Form=XmlSchemaForm.Unqualified)]
    public multiValuedAttribute[][] assets {
        get { return this.assetsField; }
        set { this.assetsField = value; }
    }
}

Which doesn’t even allow the serialization assembly to be generated!

Unable to convert type
Portfolio.WebService.multiValuedAttribute
to Portfolio.WebService.multiValuedAttribute[]

Fixing it

1 – Changing the type of the property and field

Now one of the fixes I found online is simply to remove one pair of brackets from the type of the generated property:

// No longer a jagged array, but this doesn't deserialize all data
public multiValuedAttribute[] assets;

That allows the serialization assembly to be built, and it runs without exceptions, except it doesn’t serialize the data correctly, it ‘skips’ the list of assets and deserializes the attributes of the first assets element. So it’s not a fix at all, because with this fix I can’t consume the data. For 700+ assets it gives result.assets is equal to multiValuedAttribute[2] (the 2 elements are the name and keywords attributes of the first asset).

2 – Specifying the type of the XML-elements

The second thing I tried is to give the deserializer different instructions:

[XmlArrayItemAttribute("attributes", typeof(multiValuedAttribute[]), Form=XmlSchemaForm.Unqualified)]
public multiValuedAttribute[][] assets { ... }

So now I’m telling it that each element in the sequence is of type multiValuedAttribute[]. That’s wrong because it’s still looking at attributes elements, which are of type multiValuedAttribute (single, not an array). It does run however, but now the result.assets is equal to multiValuedAttribute[2][0] and I’m still not able to get to the data.

What’s next?

I have no idea, which is why I wrote this. I can’t accept that .NET is not able to consume this web service, because it has to.

  • 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-16T13:54:03+00:00Added an answer on May 16, 2026 at 1:54 pm

    I think that you should define a separate Asset class that would have property of type multiValuedAttribute[]. So it would go something like

    public class Asset
    {
       public multiValuedAttribute[] attributes {get; set;}
    }
    
    public partial class listAssetsQueryResults {
        private Asset[] assetsField;
    
        public Asset[] assets {
    

    Then you need to decorate Asset type, attributes & assets property with some combination of XmlElement/XmlArrayElement/XmlArrayItemElement attributes to get it working.

    Needless to say, anytime you need to re-generate your proxy code, you have to re-apply above changes (perhaps you can make a batch script for that as a build action).

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

Sidebar

Related Questions

It seems to be well-known there is a bug when using JMenuItem.getRootPane(). I read
It seems that there has been a recent rising interest in STM (software transactional
I am working on implementing a JavaScript web bug that will be inserted into
For iPhone game development, seems there are very like functions using CALayer and UIView,
There seems to be no good way to localize a WPF application. MSDN seems
There seems to be a lot of heated discussion on the net about the
There seems to be two major conventions for organizing project files and then many
There seems to be three common approaches for mapping an application end user to
So there seems to be this problem with GNU Make's $(wildcard) function keeping a
It seems like there should be something shorter than this: private string LoadFromFile(string path)

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.