强制对象参数在WSDL中被序列化为可选(minOccurs / nillable / nullable问题) [英] Mandatory Object Parameter gets serialized as optional in the WSDL (minOccurs/nillable/nullable problem)
问题描述
我需要将一个对象传递给WebService方法作为第一个参数,这对于完成请求是绝对必要的。问题是,默认情况下,引用类型始终被序列化为可选。简单示例:
Hi,
I need to pass an object to a WebService Method as 1st parameter which is absolutely neccesarry for the request to complete. The problem is, by default reference types are always serialized as optional. Simple example:
推荐答案
实际上,事实上,WSDL说元素是minOccurs =" 1"毫无意义。传入的XML未针对WSDL中的模式进行验证。即使WSDL确实以某种方式说minOccurs =" 1",它也不会产生任何影响;调用者仍然可以省略参数。
Actually, the fact that the WSDL says the element is minOccurs="1" is meaningless. Incoming XML is not validated against the schemas in the WSDL. Even if the WSDL did somehow say minOccurs="1", it wouldn't make a difference; it would still be possible for a caller to omit the parameter.
您需要检查代码中的参数查看它是否为空。
You will need to check the parameter in code to see if it is null.
这篇关于强制对象参数在WSDL中被序列化为可选(minOccurs / nillable / nullable问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!