Ejemplo n.º 1
0
 /// <summary>
 /// 正式环境接收数据
 /// </summary>
 public static MyReceiveResponses Receive(string securityURL, string targetUrl, string userCode, string userPwd, ref ExchangeTransport exchangeTransport)
 {
     try
     {
         exchangeTransport = new ExchangeTransport(userCode, userPwd, "ECE91161D6670E60E040A8C0970C6ACD");
         exchangeTransport.AuthServiceUrl = securityURL;
         exchangeTransport.ServiceUrl     = targetUrl;
         exchangeTransport.Authenticate();
         if (!exchangeTransport.IsAuthValid)
         {
             throw new Exception("认证失败[" + userCode + "]");
         }
         string strResult = exchangeTransport.Receive("1");
         return(new MyReceiveResponses(strResult));
     }
     catch (Exception ex)
     {
         throw new Exception("接收出错[" + ex.Message + "]");
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 正式环境发送数据
 /// </summary>
 public static void Send(string securityURL, string targetUrl, string userCode, string userPwd, string toCode, string dataStr, ActionType actionType)
 {
     try
     {
         exchangeTransport = new ExchangeTransport(userCode, userPwd, "ECE91161D6670E60E040A8C0970C6ACD");
         exchangeTransport.AuthServiceUrl = securityURL;
         exchangeTransport.ServiceUrl     = targetUrl;
         exchangeTransport.Authenticate();
         if (!exchangeTransport.IsAuthValid)
         {
             throw new Exception("认证失败[" + userCode + "]");
         }
         string strEventID         = exchangeTransport.GetEventId(); //调用函数即可,事件ID会自动生成
         string strBaseEncodedData = exchangeTransport.Base64Encode(dataStr);
         strBaseEncodedData = exchangeTransport.Base64Encode(strBaseEncodedData);
         string      strResult = exchangeTransport.Send(toCode, strEventID, actionType.ToString(), strBaseEncodedData);
         XmlDocument xml       = new XmlDocument();
         xml.LoadXml(strResult);
         XmlNodeList nodes = xml.GetElementsByTagName("ns3:SendResult");
         if (nodes.Count > 0)
         {
             string Result = nodes[0].InnerText;
             if (Result == "false")
             {
                 throw new Exception(strResult);
             }
         }
         else
         {
             throw new Exception(strResult);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("接收者编号:[" + toCode + "] 发送出错[" + ex.Message + "]");
     }
 }