2013-02-04 35 views
2

我正在使用WSCF.blue生成基於WSDL和xsd的Web服務類。調用Web服務,我收到以下錯誤:XmlSerializer屬性在使用WCF的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; 
    } 
} 

問候

回答

2

嘗試使用/wrapped屬性來創建與svcutil代碼。

希望這會有所幫助