这有点奇怪。我最近开始使用C#,并负责从API响应解析传入的soapxml。我目前正在手动解析数据,如下所示:
var agency ="";
var doc = XDocument.Parse(xmlStr);
XNamespace ns = "urn:Blurbe";
var result = doc.Root.Descendants(ns + "IdentificationResponse")
.Descendants("IdentificationResult")
.Descendants("e")
.Descendants("r")
.Descendants("agence");
if (!string.IsNullOrEmpty(result.ToString()))
agency = result.FirstOrDefault().Value;
return agency
虽然这很有效,但显然,对于我想要提取的每个元素和属性都必须这样做是相当乏味的。因此,我被要求使用服务引用来序列化和反序列化soapxml,这样它就可以很容易地被点符号引用,并很容易地保存到DB中。
有人知道我该怎么做吗?举个例子吧?
如有任何帮助,我们将不胜感激。
海伦