【问题标题】:wse3 inherited class type not accepted as method parameterwse3 继承的类类型不被接受为方法参数
【发布时间】:2014-09-30 08:46:30
【问题描述】:

我将尝试描述我的问题。 我在代理类中有一个方法(由 wsdl 自动生成),它接受一个 BaseType 类型的对象作为其第一个参数。我尝试传递一个继承的类型,我得到了

类型 xyz 不是预期的。使用 XmlInclude 或 SoapInclude 属性指定静态未知的类型

在搜索了很多时间后,我阅读了有关命名空间和 xmlinclude 属性的信息。所以最初我有

/// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [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; .................................
.................................
public int AddSqlDatabase(BaseClass item, string groupName) {

然后我尝试添加

[System.Web.Services.WebServiceBindingAttribute(Name="esDatabaseServersSoap", Namespace="http://smbsaas/foo/bar")] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SomeOtherType))] [System.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。

我真的不知道该怎么办。请问有什么想法吗? 谢谢!

【问题讨论】:

    标签: parameter-passing wse inherited


    【解决方案1】:

    您是否尝试过将 XmlInclude 属性放入基类 - 如本文所述:Web services - XmlInclude in a derived class instead of a base class?

    但是,这只有在您拥有网络服务时才有用。

    如果只是为了一些增强(可能不是你的情况),你可以尝试使用部分类。

    【讨论】:

      猜你喜欢
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-26
      • 2023-03-29
      • 1970-01-01
      • 2016-02-19
      相关资源
      最近更新 更多