XmlSerializer 属性在使用 WCF 的 Web 服务中无效 [英] XmlSerializer attribute not valid in Web Service using WCF

查看:32
本文介绍了XmlSerializer 属性在使用 WCF 的 Web 服务中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 属性 System.Xml.Serialization.XmlAttributeAttribute 在电子邮件中无效.当 IsWrapped 为 true 时,仅支持 XmlElement、XmlArray、XmlArrayItem、XmlAnyAttribute 和 XmlAnyElement 属性."

我使用 svcutil.exe 得到了相同的结果.(VS 2010,.NET Framework 3.5)

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

有人听说过这个问题吗?

Anybody ever heard about this problem?

使用 WSDL.exe(旧的 Web 服务 .NET 2.0)生成代码会得到预期的结果,但返回值总是来自类型对象,而 WSCF.blue 会得到特定的返回值对象(例如 ResponseProfileDto 而不是对象)

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

问候

推荐答案

尝试使用 /wrapped 属性来创建带有 svcutil 的代码.

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

希望能帮到你

这篇关于XmlSerializer 属性在使用 WCF 的 Web 服务中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆