2

我使用 WSCF.blue 来生成基于 WSDL 和 xsd 的 Web 服务类。调用 Web 服务我收到以下错误:

"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."

我使用svcutil.exe. (VS 2010,.NET 框架 3.5)

有人听说过这个问题吗?

使用WSDL.exe(旧的 Web 服务 .NET 2.0)生成代码可以获得预期的结果,但返回值始终来自类型对象,因为 WSCF.blue 为我提供了特定的返回对象(例如 ResponseProfileDto 而不是对象)

其中一个类定义如下所示:

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

问候

4

1 回答 1

3

尝试使用该/wrapped属性来创建带有svcutil.

希望这可以帮助

于 2013-02-04T15:46:56.853 回答