C# 解析soap数据为json格式

数据格式:





{
    "data": {
        "dwsjxx": [{
            "SFCX": "0",
            "SFST": "02444",
            "DWH": "2100",
            "LSDWH": "30000",
            "DWMC": "办公室",
            "DWJBSJZLB_ID": 0
        }, {
            "SFCX": "0",
            "SFST": "02444",
            "DWH": "2100",
            "LSDWH": "30000",
            "DWMC": "办公室1",
            "DWJBSJZLB_ID": 1
        }]
    },
    "success": true
}




解析代码,得到return里面的数据:

            string Url = "http://############";


            X.Component.Tools.WebClient wc = new Component.Tools.WebClient();
            wc.Encoding = System.Text.Encoding.UTF8;
            var result = wc.GetHtml(Url);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(result);

            XmlElement root = doc.DocumentElement;

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");

            string value = doc.SelectSingleNode("//soap:Envelope", nsmgr).InnerText;

            X.Api.Department DepInfo = new X.Api.Department();
            JsonConvert.DeserializeObject(value); //得到json数据

  

 

你可能感兴趣的:(C# 解析soap数据为json格式)