Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 接受SOAP数据作为原始XML_C#_Xml_Web Services - Fatal编程技术网

C# 接受SOAP数据作为原始XML

C# 接受SOAP数据作为原始XML,c#,xml,web-services,C#,Xml,Web Services,我正在尝试使用System.ServiceModel命名空间编写.NET IIS web服务。我的服务将从传入的数据包中读取startTag节点作为原始XML,而不是反序列化的.NET类,但我似乎无法做到这一点。下面是一个示例SOAP数据包: 当我将上面指定的数据包发送到我的web服务时,此行: int a = iterator1.Count 引发异常: Object reference not set to an instance of an object. at MS.Inte

我正在尝试使用
System.ServiceModel
命名空间编写.NET IIS web服务。我的服务将从传入的数据包中读取
startTag
节点作为原始XML,而不是反序列化的.NET类,但我似乎无法做到这一点。下面是一个示例SOAP数据包:

当我将上面指定的数据包发送到我的web服务时,此行:

int a = iterator1.Count
引发异常:

   Object reference not set to an instance of an object.
   at MS.Internal.Xml.Cache.XPathDocumentNavigator.get_NameTable()
   at MS.Internal.Xml.Cache.XPathDocumentElementChildIterator..ctor(XPathDocumentNavigator parent, String name, String namespaceURI)
   at MS.Internal.Xml.Cache.XPathDocumentNavigator.SelectChildren(String name, String namespaceURI)
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.Query.MoveNext()
   at MS.Internal.Xml.XPath.Query.get_Count()
   at TMK.Catalog.Service1.Catalog(Point document)

我应该如何重新定义
CHRMAS03
字段,以便它将
startTag
节点的原始XML内容作为一个字符串,我可以手动解析该字符串,或者作为一个工作实例来解析任何用于读取XML的标准.NET类,例如
XmlReader
XmlNode

“startTeg/myTeg/answer”应该是“startTag/myTag/answer”?

My
XPath
查询:

startTag/myTag/answer
无法工作,因为XML在标记之间使用空格元素进行解析。我切换到
XMLDocument
,并修改代码以跳过它们:

XmlNode root = doc.DocumentElement;
foreach (XmlNode idoc in root.ChildNodes)
{
    if (idoc.Name == "#whitespace") continue;
    /* ... processing ... */
}

我认为这个空白元素导致了
XPathNodeIterator.Count
抛出。

谢谢。这只是编辑问题时出现的一个输入错误。我已经修复了它。
startTag/myTag/answer
XmlNode root = doc.DocumentElement;
foreach (XmlNode idoc in root.ChildNodes)
{
    if (idoc.Name == "#whitespace") continue;
    /* ... processing ... */
}