XMLSerialization失败 [英] XMLSerialization fails

查看:88
本文介绍了XMLSerialization失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,我获得了一堆XSD文件(美国政府使用客户自定义扩展程序的NIEM)并使用xsd.exe创建了一些c#类。 我也给了一个WSDL,只有一个调用来发送请求,我使用
wsdl.exe进行转换。

I have a project where I have been given a bunch of XSD files (US gov't NIEM with custom extensions from the customer) and used xsd.exe to create some c# classes.  I also was given a WSDL with a single call to send a request, which I converted using wsdl.exe.

我正在测试虚拟环回Web服务并且我正在测试可怕的"生成XML文档时出错" 。例外 内部例外如下:



System.InvalidOperationException未处理

  Message ="生成XML文档时出错。

  InnerException:System.InvalidOperationException

 

       Message =" 不预期类型Inquiry_Request.MessageType

      使用XmlInclude或SoapInclude属性指定静态未知的类型。"

 

MessageType 是顶级对象层次结构,一切都挂掉它。 根据我在对象浏览器和intellisense中看到的结构,该结构基于其提供的文档看起来有效。

I am testing against a dummy loopback web service and am getting the dreaded "There was an error generating the XML document" exception.  The inner exception is below:

System.InvalidOperationException was unhandled
  Message="There was an error generating the XML document."
  InnerException: System.InvalidOperationException
 
       Message="The type Inquiry_Request.MessageType was not expected .
       Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."
 
MessageType is the top-level object in the hierarchy, and everything hangs off it.  From what I can see in the object browser and in intellisense, the structure looks valid based on their supplied documentation.

我希望我不必修改xsd的输出文件,对于每个人来说,生成了多少个自定义数据类型。 根据我的理解,你不应该这样做。

I would hope that I do not have to modify the output files from xsd, for each off the who-knows-how-many custom datatypes are getting generated.  You aren't supposed to do that anyway, from what I understand.

我的问题只是我的目标网络服务只是一个环回,如果我连接我的问题将得到解决真实的,名称空间,数据类型等都是已知且一致的吗?

Is my problem just that my target web service is just a loopback, and that my problems will be resolved if I connect to the real thing, where the namespaces, datatypes, etc, are all known and consistent?

无论如何,我非常喜欢这个菜鸟,并且非常感谢任何人提供的建议。

Anyway, I am very much a noob at this and would appreciate any suggestions anyone might offer.

Ed

 



推荐答案

您必须告诉XML Serializer它将序列化的类型和反序列化,或者它不知道如何做到这一点。
You have to tell the XML Serializer what types it will have to serialize and deserialize, or it won't know how to do that.


这篇关于XMLSerialization失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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