我正在使用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 Framework 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;
}
}
此致
答案 0 :(得分:2)
尝试使用/wrapped
属性创建包含svcutil
的代码。
希望这有帮助