Example #1
0
 /// <summary>
 /// 固定接收一条数据
 /// </summary>
 /// <param name="securityURL"></param>
 /// <param name="targetUrl"></param>
 /// <param name="userCode"></param>
 /// <param name="userPwd"></param>
 /// <returns></returns>
 public static UReceiveResponse Receive_Test(string securityURL, string targetUrl, string userCode, string userPwd, ref UUserToken _token)
 {
     try
     {
         UserSecurityImpl imp = new UserSecurityImpl(securityURL);
         _token = imp.authenticate(userCode, userPwd);
         UExchangeTransportImpl ueti           = new UExchangeTransportImpl(targetUrl);
         UReceiveRequest        receiveRequest = new UReceiveRequest(userCode, 1);
         try
         {
             UReceiveResponse response = ueti.receive(_token, receiveRequest);
             return(response);
         }
         catch (UCommonFaultType ex)
         {
             throw new Exception(string.Format("接收失败[失败代码:{0} 失败内容:{1}]", ex.getCodeField().Trim(), ex.getErrorMessageField().Trim()));
         }
         catch (Exception ex)
         {
             throw new Exception("接收出现错误或者没有数据接收:" + ex.GetBaseException());
         }
     }
     catch (Exception ex)
     {
         throw new Exception("接收出错[" + ex.Message + "]");
     }
 }
Example #2
0
 public static void Send_Test(string securityURL, string targetUrl, string userCode, string userPwd, string toCode, string dataStr, ActionType actionType)
 {
     try
     {
         UserSecurityImpl       imp    = new UserSecurityImpl(securityURL);
         UUserToken             _token = imp.authenticate(userCode, userPwd);
         UExchangeTransportImpl iet    = new UExchangeTransportImpl(targetUrl);
         string[] toAddress            = new string[] { toCode }; //接收者地址
         //string actionType = "LOGINK_CN_TRANSPORT_PREBOOKING";           //接收者地址
         int          sendType    = 2;                            //定义好发送事件类型   1:简单值(即键值对)(类型为 Dictionary ) 2: xml文档,类型为 string
         string       sendData    = dataStr;                      //定义好数据信息 sendData 类型参照 sendType 的定义(即1为 Dictionary, 2为 string);
         USendRequest sendRequest = new USendRequest(toAddress);
         sendRequest.addSendEvent(actionType.ToString(), sendType, sendData);
         String        eventId      = sendRequest.getExchangeEvent().getEventId();
         USendResponse sendResponse = iet.send(_token, sendRequest);
         if (!sendResponse.SendResult)
         {
             throw new Exception(string.Format("发送失败[事件编号:{0} 异常代码:{1} 异常消息:{2} 接收者编号:{3}]", eventId, sendResponse.Fault.getCodeField().Trim(), sendResponse.Fault.getErrorMessageField().Trim(), toCode));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("接收者编号:[" + toCode + "] 发送出错[" + ex.Message + "]");
     }
 }