首页 > 解决方案 > XML 的 xsi:nil 不反序列化为 null

问题描述

我有一个 C# 项目,我从现有的 dll 中反编译了它。它使用 Microsoft.Web.Services2 和 System.Web.Services。我的客户没有消息来源,所以你知道 ;D

有一个从 WSDL 合同生成的方法:

[SoapDocumentMethod("", ParameterStyle = SoapParameterStyle.Bare, Use = SoapBindingUse.Literal)]
[return: XmlElement("getOutputMessageResponse", Namespace = "http://www.ibm.com/xmlns/prod/websphere/human-task/services/6.0")]
public XmlElement getOutputMessage([XmlElement("getOutputMessage", Namespace = "http://www.ibm.com/xmlns/prod/websphere/human-task/services/6.0")] getOutputMessage getOutputMessage1)
{
  return (XmlElement) this.Invoke("getOutputMessage", new object[1]
  {
    (object) getOutputMessage1
  })[0];
}

在代码中,我得到了这个:

XmlElement output = ... // getOutputMessage() invocation

if(output != null){
    // do something...
}else{
    // do something else
}

这就是问题所在。输出永远不会为空。它要么变成:

<wn:procesResponse xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn="http://website" />

或正确填写的XML回复。

由于 ,它应该被null编辑xsi:nil,最好的部分是 - 它在反编译之前工作,所以我缺少一些设置或类似的东西。

你有什么想法,这里可能有什么问题?

谢谢你的帮助!

标签: c#xmlweb-servicessoapxml-deserialization

解决方案


推荐阅读