从BizTalk diffgram中读取XML响应

本文关键字:XML 响应 读取 BizTalk diffgram | 更新日期: 2023-09-27 18:01:29

我需要在c#中读取来自BizTalk服务的响应内容,该服务发送称为diffgram的内容。我使用SoapUI来查看服务是否正在响应。

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <ejecutaDqlResponse xmlns="http://tempuri.org/">
         <ejecutaDqlResult>
            <xs:schema id="dql" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
               <xs:element name="dql" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
                  <xs:complexType>
                     <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="Table1">
                           <xs:complexType>
                              <xs:sequence>
                                 <xs:element name="r_object_id" type="xs:string" minOccurs="0"/>
                                 <xs:element name="n_tipo_docto" type="xs:string" minOccurs="0"/>
                                 <xs:element name="n_fecha_celbrcn" type="xs:string" minOccurs="0"/>
                              </xs:sequence>
                           </xs:complexType>
                        </xs:element>
                     </xs:choice>
                  </xs:complexType>
               </xs:element>
            </xs:schema>
            <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
               <dql xmlns="">
                  <Table1 diffgr:id="Table11" msdata:rowOrder="0" diffgr:hasChanges="inserted">
                     <r_object_id>0902c09e80109543</r_object_id>
                     <n_tipo_docto>Asambleas de Accionistas 1.- Acta</n_tipo_docto>
                     <n_fecha_celbrcn>1/1/2014 12:00:00 AM</n_fecha_celbrcn>
                  </Table1>
                  <Table1 diffgr:id="Table12" msdata:rowOrder="1" diffgr:hasChanges="inserted">
                     <r_object_id>0902c09e8010a95a</r_object_id>
                     <n_tipo_docto>Asambleas de Accionistas Extraordinarias</n_tipo_docto>
                     <n_fecha_celbrcn>3/14/2015 12:00:00 AM</n_fecha_celbrcn>
                  </Table1>
               </dql>
            </diffgr:diffgram>
         </ejecutaDqlResult>
      </ejecutaDqlResponse>
   </s:Body>
</s:Envelope>

我唯一需要做的就是计算这个响应中存在的不同的r_object_id。但我不知道该怎么做。我尝试了数据集。读取xml,但不能工作。

有人能帮我吗?

从BizTalk diffgram中读取XML响应

尝试xml linq

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
    class Program
    {
        const string FILENAME = @"c:'temp'test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);
            XElement diffgram = doc.Descendants().Where(x => x.Name.LocalName == "diffgram").FirstOrDefault();
            var results = diffgram.Descendants("r_object_id").Select(x => new {
                r_object_id = (string)x
            }).ToList();
        }
    }
}