//发送传真 protected void btnSendFax_Click(object sender, EventArgs e) { string path = GetImageByWeb(); if (!File.Exists(path + ".jpg")) { path = GetImageByWeb(); } //detailMessageContent.InnerHtml = "Message:" + path; FaxService fax = new FaxService(); fax.Timeout = 1200000; string xml = ""; //ToServiceXML.getSendFaxToServerXMLStr(path + ".jpg"); //拼装xml数据 string sendFaxToServerBack = fax.SendFaxToServer(xml); //开始远程调用 string sendFaxToServerBack1 = sendFaxToServerBack.Replace(">", ">\r\n"); //tb_XML.Text = sendFaxToServerBack1; ///////////////////////////////////解析反馈结果/////////////////////////////////////// XmlDocument m_XmlDoc = new XmlDocument(); try { m_XmlDoc.LoadXml(sendFaxToServerBack); XmlNamespaceManager nsmgr = new XmlNamespaceManager(m_XmlDoc.NameTable); XmlNodeList nodeList = m_XmlDoc.ChildNodes; XmlNode node = nodeList.Item(1); string ErrorFlag = node.FirstChild.SelectSingleNode("Header").SelectSingleNode("ErrorFlag").InnerText; string ReturnMessage = node.FirstChild.SelectSingleNode("Header").SelectSingleNode("ReturnMessage").InnerText; string JobNo = ""; string JobResult = ""; string TotalNum = ""; string ValidNum = ""; try { JobNo = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("JobNo").InnerText; JobResult = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("JobResult").InnerText; TotalNum = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("TotalNum").InnerText; ValidNum = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("ValidNum").InnerText; } catch (Exception ex) { ex.GetBaseException(); } string queryResultS = ""; queryResultS = queryResultS + "ErrorFlag :" + ErrorFlag + "\r\n" + "ReturnMessage:" + ReturnMessage + "\r\n" + "JobNo :" + JobNo + "\r\n" + "JobResult :" + JobResult + "\r\n" + "TotalNum :" + TotalNum + "\r\n" + "ValidNum :" + ValidNum + "\r\n"; //tb_SendFaxToServer.Text = queryResultS; //File.Delete(path); detailMessageContent.InnerHtml = "Message:" + ReturnMessage; } catch (Exception ex) { ex.GetBaseException(); } }
public static string SendFax(string type, string orderID, string path, string fileName, string ContentType, string ClientTaskID, string FaxNumber, string faxType) { string sendFaxToServerBack = ""; try { FaxService fax = new FaxService(); fax.Timeout = 1200000; string xml = ToServiceXML.getSendFaxToServerXMLStr(path, fileName, ContentType, ClientTaskID, FaxNumber); //拼装xml数据 sendFaxToServerBack = fax.SendFaxToServer(xml); //开始远程调用 string sendFaxToServerBack1 = sendFaxToServerBack.Replace(">", ">\r\n"); } catch (Exception ex) { ex.GetBaseException(); return "递交失败,请重试!"; } ///////////////////////////////////解析反馈结果/////////////////////////////////////// XmlDocument m_XmlDoc = new XmlDocument(); string queryResultS = ""; try { m_XmlDoc.LoadXml(sendFaxToServerBack); XmlNamespaceManager nsmgr = new XmlNamespaceManager(m_XmlDoc.NameTable); XmlNodeList nodeList = m_XmlDoc.ChildNodes; XmlNode node = nodeList.Item(1); string ErrorFlag = node.FirstChild.SelectSingleNode("Header").SelectSingleNode("ErrorFlag").InnerText; string ReturnMessage = node.FirstChild.SelectSingleNode("Header").SelectSingleNode("ReturnMessage").InnerText; string JobNo = ""; string JobResult = ""; string TotalNum = ""; string ValidNum = ""; try { JobNo = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("JobNo").InnerText; JobResult = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("JobResult").InnerText; TotalNum = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("TotalNum").InnerText; ValidNum = node.FirstChild.SelectSingleNode("SendFaxToServerResponse").SelectSingleNode("SendFaxToServerResult").SelectSingleNode("ValidNum").InnerText; } catch (Exception ex) { ex.GetBaseException(); } queryResultS = queryResultS + "ErrorFlag :" + ErrorFlag + "\r\n" + "ReturnMessage:" + ReturnMessage + "\r\n" + "JobNo :" + JobNo + "\r\n" + "JobResult :" + JobResult + "\r\n" + "TotalNum :" + TotalNum + "\r\n" + "ValidNum :" + ValidNum + "\r\n"; OrderFaxDetialUpdate(type, JobNo, path, ErrorFlag, orderID, ClientTaskID, faxType); return ReturnMessage; } catch (Exception ex) { ex.GetBaseException(); return "递交失败,请重试!"; } }