user2039915
user2039915

Reputation: 21

XmlSerializer attribute not valid in Web Service using WCF

I'm using WSCF.blue for generating the web service classes based on the WSDL and xsd. Calling the web service I receive the following error:

"XmlSerializer attribute System.Xml.Serialization.XmlAttributeAttribute is not valid in Email. Only XmlElement, XmlArray, XmlArrayItem, XmlAnyAttribute and XmlAnyElement attributes are supported when IsWrapped is true."

I'm getting the same result using svcutil.exe. (VS 2010, .NET Framework 3.5)

Anybody ever heard about this problem?

Generating the code using WSDL.exe (old web service .NET 2.0) gets me the expected result but the return value is always from type object where as the WSCF.blue gets me a specific return object (e.g. ResponseProfileDto instead of object)

One of the class definitions looks like the following:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="ResendEmailRequest", WrapperNamespace="http://xy.com/test", IsWrapped=true)]
public partial class ResendEmailRequest
{

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://xy.com/test", Order = 0, Name = "Email")]
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string Email;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://xy.com/test", Order = 1, Name = "LoginName")]
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string LoginName;

    public ResendEmailRequest()
    {
    }

    public ResendEmailRequest(string Email, string LoginName)
    {
        this.Email = Email;
        this.LoginName = LoginName;
    }
}

Regards

Upvotes: 2

Views: 2802

Answers (1)

tBX
tBX

Reputation: 184

Try using the /wrapped attribute to create the code with the svcutil.

Hope this helps

Upvotes: 4

Related Questions