WCF服务(请遵循架构) [英] WCF Service (Please respect the schema)

查看:85
本文介绍了WCF服务(请遵循架构)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WCF自托管服务,其中包含许多Web方法.一种方法是"GetSomeData(myOuterType)".需要类型为MyOuterType的参数.MyOuterType具有类型为MyInnerType的属性.   MyInnerType是使用XSD从架构中生成的.直到Java客户端出现并指出当它尝试使用有效的架构实例xml调用服务时,该服务都可以很好地工作,否则服务会阻塞.使用WCF日志,我可以拉 删除由我的.Net客户端生成的XML.显然,它不符合架构中定义的Xml.即使架构将元素定义为按顺序排列,元素的顺序也被弄乱了.除了元素的顺序, 我认为这还可以.

I have a WCF Self-hosted service with many web methods. One method, "GetSomeData(myOuterType)" requires a parameter of type MyOuterType.MyOuterType has a property of type MyInnerType.  MyInnerType was generated using XSD from a schema. It all works very well until a java client comes along and points out that when it tries to call the service using valid schema instance xml, the service chokes. Using WCF logs, I can pull out the XML that gets generated by my .Net client. It clearly does not conform to the Xml defined in the schema. The order of elements are all messed up even though the schema defines the elements to be in a sequence. Other than the order of the elements, I think it seems ok.

对于新客户端无法在其中发送有效的架构实例,我有些尴尬它们的SOAP信封,因为我应该遵循该模式.我寄给他们一份 我的.Net客户端生成的SOAP信封,如果使用相同的顺序,则Java客户端可以正常工作.

I'm a little embarrassed that the new client cannot send a valid schema instance in their SOAP envelope since I am supposed to be conforming to the schema. I sent them a copy of the SOAP envelope my .Net client generates and if they use the same order, their java client works fine.

我想了解为什么我的服务不需要或接受格式正确的xml在SOAP信封中.

我还想学习如何制作一个.net客户端代理为SOAP信封生成有效的xml.

感谢您提供的任何见解.这里有一些细节,以防万一;

IService;

[ ]

DataPackage MyOuterType

DataPackage GetSomeData(MyOuterType myOuterType);

 

  • 我可以使用XmlSerializer将MyInnerType序列化为xml,并且该xml确实针对该模式进行了验证.
  • 如果我修改服务合同并使用 [ XmlSerializerFormat ]属性,当服务尝试启动时,我收到一条错误消息;不能包含匿名 键入"MyInnerType".
  • I can use XmlSerializer to serialize MyInnerType to xml and that xml does validate against the schema.
  • If I modify the service contract and use the [XmlSerializerFormat] attribute, I get an error message when the service tries to start;"Cannot include anonymous type 'MyInnerType'.

 

以下内容是由XSD.exe生成的;

///<备注/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd","2.0.50727.1432"))]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code"))
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace =",IsNullable = false)]
公共局部类MyInnerType

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class MyInnerType

 

 

 

 

 

 

 

推荐答案

请发布架构,生成的代码(上面没有出现)以及生成代码的方式(例如添加服务引用",svcutil等.)
Please publish the schema, the generated code (it does not appear well above) and how you generated the code (e.g. "add service reference", svcutil etc.)


这篇关于WCF服务(请遵循架构)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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