2014-09-30 88 views
0

我將嘗試描述我的問題。 我有一個代理類的方法(自動產生由WSDL),其接受作爲第一個參數類型BaseType.I的目的試圖通過繼承的類型和我得到wse3繼承的類類型不被接受爲方法參數

是沒有預料到的類型的xyz 。使用XmlInclude或SoapInclude屬性來指定不是靜態

知名搜索了大量的時間後類型我也讀到了命名空間以及有關xmlinclude attribute.So最初我有

/// [System.CodeDom.Compiler.GeneratedCodeAttribute( 「WSDL」, 「2.0.50727.3038」)] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute( 「代碼」)] [System.Web程序。 Services.WebServiceBindingAttribute(Name =「esDatabaseServersSoap」,Namespace =「http:// smbsaas/foo/bar」)] [System.Xml.Serialization.XmlIncludeAttribute(typeof運算(SomeOtherType))]
公共部分類esDatabaseServers:Microsoft.Web.Services3.WebServicesClientProtocol { 私人System.Threading.SendOrPostCallback GetRawSqlDatabasesPagedOperationCompleted; ................................................
................................................
公衆詮釋AddSqlDatabase(BaseClass的項,串組名){

,然後我嘗試添加

[System.Web.Services.WebServiceBindingAttribute(名稱= 「esDatabaseServersSoap」,命名空間=」 http:// smbsaas/foo/bar「)] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SomeOtherType))] [Syst em.Xml.Serialization.XmlIncludeAttribute(typeof運算(MyInheritedType))] 我增加這一行
公共部分類esDatabaseServers:

我得到

的System.Web。 Services.Protocols.SoapException:System.Web.Services.Protocols.SoapException:服務器無法讀取請求。 ---> System.InvalidOperationException:XML文檔中存在錯誤。 ---> System.InvalidOperationException:指定的類型未被識別:name ='MyInheritedType',namespace =「http:// smbsaas/foo/bar」,at。

MyInheritedType繼承自baseClass。

我真的不知道該怎麼辦。請給點意見嗎? 謝謝!

回答

0

你有沒有試圖把XmlInclude屬性的基類 - 在這篇文章中提到:Web services - XmlInclude in a derived class instead of a base class?

但是隻有在你自己的Web服務,這將是有益的。

如果只是針對某些增強功能(可能不是您的情況),則可以嘗試使用部分類。

+0

我把它放在錯誤的位置......謝謝。 – tasoss 2014-10-22 08:08:00

相關問題