public string accountService(string optype, string paramxml) { XmlDocument rtdoc = null; ParameterHandler handler = null; try { handler = parameterHanding(paramxml); if (m_processors.ContainsKey(optype)) { OperatorHandleProcessor processor = m_processors [optype]; rtdoc = processor(handler); } else { rtdoc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, "未知的操作请求,请确认后重新发送"); } } catch (Exception ex) { rtdoc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, AppUtils.Content_Payment_Excp + "[" + ex.StackTrace + "]"); } XmlDeclaration delar = rtdoc.CreateXmlDeclaration("1.0", "utf-8", "no"); XmlElement droot = rtdoc.DocumentElement; rtdoc.InsertBefore(delar, droot); return(rtdoc.OuterXml); }
private static ParameterHandler parameterHanding(string paramxml) { if (string.IsNullOrEmpty(paramxml)) { return(null); } XmlDocument doc = XmlHelper.CreateXmlDocument(paramxml); XmlNodeList childList = doc.DocumentElement.ChildNodes; Dictionary <String, String> dic = new Dictionary <string, string> (); foreach (XmlNode child in childList) { string tagname = child.Name; string tagvalue = child.InnerText /*.Trim ()*/; if (tagvalue == "null" || tagvalue == "NULL") { tagvalue = null; } dic.Add(tagname, tagvalue); } ParameterHandler handler = new ParameterHandler(dic); return(handler); }
public string accountService(string optype, string paramxml) { XmlDocument rtdoc = null; ParameterHandler handler = null; log4net.Config.XmlConfigurator.Configure();//系统日志配置 ILog logger = LogManager.GetLogger("log"); try { logger.Info(optype + ":" + paramxml.Replace("<![CDATA[", "").Replace("]]>", "")); handler = parameterHanding(paramxml); if (m_processors.ContainsKey(optype)) { OperatorHandleProcessor processor = m_processors[optype]; rtdoc = processor(handler); } else { rtdoc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, "未知的操作请求,请确认后重新发送"); } } catch (Exception ex) { rtdoc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, AppUtils.Content_Payment_Excp + "[" + ex.StackTrace + "]"); logger.Error(rtdoc.OuterXml); } if (optype == "FY030315") { return("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?><root><result>success</result><message>FY030315接口被调用</message></root>"); } //if (optype == "FY030306") //{ // logger.Debug(ReplyXmlDoc.GetWaitXml("程序未响应,请等待...").OuterXml); // return "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><message><value><msg>fail</msg><msg2>100抱歉,候诊时间已过!2017-5-4 16:35:00</msg2></value></message><result>success</result></root>"; //} if (optype == "FY030303" || optype == "FY030305" || optype == "FY030306" || optype == "OR030204" || optype == "OR030205" || optype == "OR030206") { logger.Debug(rtdoc.OuterXml); //XmlDocument xdoc = new XmlDocument(); //xdoc.LoadXml(rtdoc.OuterXml); //XmlNode root = xdoc.SelectSingleNode("//result");//当节点Workflow带有属性是,使用SelectSingleNode无法读取 //string result = root.InnerText; //if (result == "fail") //{ // return "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><result>fail</result><message><status>-1</status><remark>操作失败</remark></message></root>"; //} return(rtdoc.OuterXml.Replace("<result>fail</result>", "<result>success</result>")); } XmlDeclaration delar = rtdoc.CreateXmlDeclaration("1.0", "utf-8", "no"); XmlElement droot = rtdoc.DocumentElement; rtdoc.InsertBefore(delar, droot); return(rtdoc.OuterXml); }