C# Linq方式生成SAP对接的XML格式内容(一般处理程序 ashx )
2021-05-23 03:28
标签:opened RoCE end 处理 mon oid new man 数据 Linq生成XML的方法: 生成结果格式: 访问方法: C# Linq方式生成SAP对接的XML格式内容(一般处理程序 ashx ) 标签:opened RoCE end 处理 mon oid new man 数据 原文地址:https://www.cnblogs.com/lzsin/p/11163722.html string CreateXML(string strkey, string strDATAJSON)
{
XDeclaration dec = new XDeclaration("1.0", "UTF-8", null);
XDocument xdoc = new XDocument();
XNamespace saop = "http://schemas.xmlsoap.org/soap/envelope/";
XNamespace ns0 = "http://www.db.com";
XElement root = new XElement(saop + "Envelope",
new XAttribute(XNamespace.Xmlns + "soap", "http://schemas.xmlsoap.org/soap/envelope/"),
new XElement(saop + "Body",
new XElement(ns0 + "MT_COMMON_RET",
new XAttribute(XNamespace.Xmlns + "ns0", "http://www.db.com"),
new XElement("KEY", strkey),
new XElement("DATAJSON_RET", strDATAJSON)))
);
xdoc.Add(root);
string strdoc = dec.ToString();//@"";
return strdoc + xdoc.ToString();
}
"1.0" encoding="UTF-8"?>
public void ProcessRequest(HttpContext context)
{
int rowcount = (int)context.Request.InputStream.Length;
byte[] buff = new byte[rowcount];
context.Request.InputStream.Read(buff, 0, rowcount);
string text = System.Text.Encoding.UTF8.GetString(buff);
Log4.WriteLog("Handler非标接收数据:" + text ?? "");
/***********************************************************/
Dictionarystring, object> dic = new Dictionarystring, object>();
dic.Add("AAA", "0000");
dic.Add("BBB", "0000");
string strDATAJSON = Common.Tools.ConvertToJsonStr(dic);
string strxml = CreateXML("KEY值", strDATAJSON);
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.AddHeader("Content-Length", strxml.Length.ToString());
context.Response.ContentType = "text/xml";
context.Response.Write(strxml);
context.Response.Flush();
context.Response.End();
}
文章标题:C# Linq方式生成SAP对接的XML格式内容(一般处理程序 ashx )
文章链接:http://soscw.com/index.php/essay/88090.html