tags:

views:

63

answers:

1

Hi,

I have some generated proxy classes, that contain properties with the XMLAttribute attribute, e.g.

[System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace="http://www.egem.nl/StUF/StUF0301")]
public Verwerkingssoort verwerkingssoort
{
    get
    {
        return this.verwerkingssoortField;
    }
    set
    {
        this.verwerkingssoortField = value;
    }
}

This and several other properties don't show up in the SOAP message however. The proxies were generated using svcutil.

As I'm writing this question I notice that the properties that do show up as attributes are strings, while this is an Enum (but I haven't done a thorough check, yet). Does somebody know if this is the problem, or what else it could be and what possible solutions there are?

Update: After some more checking, I found that no Enums are included as attribute, but Strings and Bools work fine.

Update 2: In a simple case an Enum as attribute is serialized just fine.

Update 3: If I replace XmlAttributeAttribute(...) with XmlIgnoreAttribute() and add the following property:

[System.Xml.Serialization.XmlAttributeAttribute("verwerkingssoort")]
public string verwerkingssoortString
{
    get
    {
        return this.verwerkingssoortField.ToString();
    }
    set
    {
        this.verwerkingssoortField = (Verwerkingssoort)System.Enum.Parse(typeof(Verwerkingssoort), value, true);
    }
}

it works fine, but making changes like this throughout the generated code would be a rather Herculean task, and when the contract changes, I would need to do it all over again. So I'm still looking for a better solution.

Update 4: It turns out that this problem is not limited to attributes. I just noticed that a property that should be serialized to an element is omitted as well. The same things apply: it is an Enum, and it works fine if I change it to a string.

Thanks, regards,

Miel.

A: 

Have you tried setting Type property of the XmlAttributeAttribute class to the type of your enum?

decyclone
When I try that in the referenced simple case, I get an excpetion (in Dutch :( ), that the Type for XmlAttribute can not be given for primitive types.
Miel