コード例 #1
0
        public PluginsInterfaces.Message createReplyMessageAxapta(axaptaGate.sendMessageResponse response, PluginsInterfaces.Message message)
        {
            PluginsInterfaces.Message newMessage = new PluginsInterfaces.Message();
            try
            {
                string SoapResp = @"<ResponseArg  xmlns=""http://schemas.datacontract.org/2004/07/"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
                                 <resultStatus>" + response.Body.sendMessageResult.resultStatus + @"</resultStatus>
                                 <resultLocation>" + response.Body.sendMessageResult.resultLocation + @"</resultLocation>
                                 <resultCode>" + response.Body.sendMessageResult.resultCode + @"</resultCode>
                                 <resultMessage><![CDATA[" + response.Body.sendMessageResult.resultMessage + @"]]></resultMessage> 
                                 <resultRecId>" + response.Body.sendMessageResult.resultRecId + @"</resultRecId>                   
                                 <resultTableId>" + response.Body.sendMessageResult.resultTableId + @"</resultTableId>                  
                                <resultDocNum>" + response.Body.sendMessageResult.resultDocNum + @"</resultDocNum>
                                </ResponseArg>";

                newMessage.Body               = Encoding.UTF8.GetBytes(SoapResp);
                newMessage.ClassId            = message.ClassId;
                newMessage.Id                 = Guid.NewGuid();
                newMessage.Type               = message.Type;
                newMessage.CorrelationId      = message.CorrelationId;
                newMessage.Receiver           = message.Source;
                newMessage.NeedAcknowledgment = true;
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
            }
            return(newMessage);
        }
コード例 #2
0
 public bool HandleMessage(PluginsInterfaces.Message message, IMessageReplyHandler replyHandler)
 {
     try
     {
         if (_connectionPoint == "1C")
         {
             BPMExchangePortTypeClient ws = connectionServiceUT(_password, _login);
             var receiptMethod            = ws.SendMessageAsync(createOutgoingMessageUT(message)).ConfigureAwait(false).GetAwaiter();
             receiptMethod.OnCompleted(() =>
             {
                 try
                 {
                     var replyMessage = createReplyMessageUT(receiptMethod.GetResult(), message);
                     replyHandler.HandleReplyMessage(replyMessage);
                     _logger.Debug("Ответ сформирован :" + Encoding.UTF8.GetString(replyMessage.Body));
                     ws.Close();
                 }
                 catch (Exception ex)
                 {
                     replyHandler.HandleReplyMessage(createAndSendCatchMessage(ex.Message, message));
                     _logger.Error(ex.Message);
                     ws.Abort();
                 }
             });
         }
         else if (_connectionPoint == "Axapta")
         {
             IntegrationaxSoapClient ws = connectionAxapteService();
             var receiptMethod          = ws.sendMessageAsync(createOutgoingMessageAxapta(message)).ConfigureAwait(false).GetAwaiter();
             receiptMethod.OnCompleted(() =>
             {
                 try
                 {
                     var replyMessage = createReplyMessageAxapta(receiptMethod.GetResult(), message);
                     replyHandler.HandleReplyMessage(replyMessage);
                     _logger.Debug("Ответ сформирован :" + Encoding.UTF8.GetString(replyMessage.Body));
                     ws.Close();
                 }
                 catch (Exception ex)
                 {
                     replyHandler.HandleReplyMessage(createAndSendCatchMessage(ex.Message, message));
                     _logger.Error(ex.Message);
                     ws.Abort();
                 }
             });
         }
     }
     catch (Exception ex)
     {
         _logger.Error("Ошибка HandleMessage " + ex.Message);
     }
     return(true);
 }
コード例 #3
0
 public axaptaGate.RequestArg createOutgoingMessageAxapta(PluginsInterfaces.Message esbMessage)
 {
     axaptaGate.RequestArg AxaptaMessage = new axaptaGate.RequestArg();
     try
     {
         AxaptaMessage.Body              = Encoding.UTF8.GetString(esbMessage.Body);
         AxaptaMessage.ClassId           = esbMessage.ClassId;
         AxaptaMessage.DestinationServer = _system;
         AxaptaMessage.ExternalSystem    = _server;
         AxaptaMessage.Id   = esbMessage.Id.ToString();
         AxaptaMessage.Type = esbMessage.Type;
     }
     catch (Exception ex)
     {
         _logger.Error("Ошибка createOutgoingMessageAxapta " + ex.Message);
     }
     return(AxaptaMessage);
 }
コード例 #4
0
 public BPMExchange.RequestArg createOutgoingMessageUT(PluginsInterfaces.Message esbMessage)
 {
     BPMExchange.RequestArg BPMMessage = new BPMExchange.RequestArg();
     try
     {
         BPMMessage.Body              = Encoding.UTF8.GetString(esbMessage.Body);
         BPMMessage.ClassId           = int.Parse(esbMessage.ClassId);
         BPMMessage.DestinationServer = _server;
         BPMMessage.ExternalSystem    = _system;
         BPMMessage.Id   = esbMessage.Id.ToString();
         BPMMessage.Type = esbMessage.Type;
     }
     catch (Exception ex)
     {
         _logger.Error(ex.Message);
     }
     return(BPMMessage);
 }
コード例 #5
0
        public PluginsInterfaces.Message createAndSendCatchMessage(string ex, PluginsInterfaces.Message esbMessage)
        {
            string SoapResp = @"<ResponseArg  xmlns=""http://schemas.datacontract.org/2004/07/"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
                                 <resultStatus>False</resultStatus>
                                 <resultLocation>UT</resultLocation>
                                 <resultCode>0</resultCode>
                                 <resultMessage><![CDATA[" + ex + @"]]></resultMessage> 
                                 <resultRecId>0</resultRecId>                   
                                 <resultTableId>0</resultTableId>                  
                                <resultDocNum>0</resultDocNum>
                                </ResponseArg>";

            PluginsInterfaces.Message newMessage = new PluginsInterfaces.Message();
            newMessage.Body               = Encoding.UTF8.GetBytes(SoapResp);
            newMessage.ClassId            = esbMessage.ClassId;
            newMessage.Id                 = Guid.NewGuid();
            newMessage.Type               = esbMessage.Type;
            newMessage.CorrelationId      = esbMessage.CorrelationId;
            newMessage.Receiver           = esbMessage.Source;
            newMessage.NeedAcknowledgment = true;
            return(newMessage);
        }
コード例 #6
0
        public void receiptMessage(PluginsInterfaces.Message _inMessage, string _ulr, string _password, string _login)
        {
            //string OutResp;
            //var data = _inMessage.Body;
            //string outMessage = "";

            //try
            //{
            //    string soapEnv = @"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:bpm=""http://srv-1c-web.patio-minsk.by/BPMExchange/"">
            //        <soapenv:Header/>
            //         <soapenv:Body>
            //            <bpm:SendMessage>
            //                <bpm:Request>
            //                    <bpm:Id>5</bpm:Id>
            //                    <bpm:Type>" + _inMessage.Type + @"</bpm:Type>
            //                    <bpm:ClassId>" + _inMessage.ClassId + @"</bpm:ClassId>
            //                    <bpm:Body><![CDATA[" + Encoding.UTF8.GetString(data) + @"]]></bpm:Body>
            //                    <bpm:ExternalSystem>?</bpm:ExternalSystem>
            //                    <bpm:DestinationServer>?</bpm:DestinationServer>
            //                </bpm:Request>
            //            </bpm:SendMessage>
            //        </soapenv:Body>
            //    </soapenv:Envelope>";

            //    _logger.Debug("Сформированное тело для отправки \n" + soapEnv);
            //    //Запрос
            //    WebRequest request = HttpWebRequest.Create(_ulr);
            //    request.Credentials = new NetworkCredential(_login, _password);

            //    request.Method = "POST";
            //    request.ContentType = "text/xml; charset=UTF-8";
            //    request.ContentLength = soapEnv.Length;
            //    request.Headers.Add("SOAPAction", "http://srv-1c-web.patio-minsk.by/BPMExchange/#BPMExchange:SendMessage");


            //    //Пишем тело
            //    StreamWriter sw = new StreamWriter(request.GetRequestStream());
            //    sw.Write(soapEnv);
            //    sw.Close();
            //    //Читаем ответ
            //    WebResponse response = request.GetResponse();
            //    StreamReader reader = new StreamReader(response.GetResponseStream());
            //    OutResp = reader.ReadToEnd();
            //    reader.Close();

            //    XmlDocument docXML = new XmlDocument(); //Xml документ
            //    docXML.LoadXml(OutResp); // Загрузка xml
            //    XmlNamespaceManager _namespaceManager = new XmlNamespaceManager(docXML.NameTable); // Инициализация NS
            //    _namespaceManager.AddNamespace("m", "http://srv-1c-web.patio-minsk.by/BPMExchange/");
            //    _namespaceManager.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");

            //    string _status = docXML.DocumentElement.SelectNodes("/soap:Envelope/soap:Body/m:SendMessageResponse/m:return/m:resultStatus", _namespaceManager)[0].InnerXml;
            //    string _body = docXML.DocumentElement.SelectNodes("/soap:Envelope/soap:Body/m:SendMessageResponse/m:return/m:resultMessage", _namespaceManager)[0].InnerXml;

            //    string SoapResp = @"<ResponseArg  xmlns=""http://schemas.datacontract.org/2004/07/"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
            //                     <resultStatus>" + _status + @"</resultStatus>
            //                     <resultLocation>UT</resultLocation>
            //                     <resultCode>0</resultCode>
            //                     <resultMessage>" + _body + @"</resultMessage>
            //                     <resultRecId>0</resultRecId>
            //                     <resultTableId>0</resultTableId>
            //                    <resultDocNum>0</resultDocNum>
            //                    </ResponseArg>";

            //    _logger.Debug("Сформирован ответ :" + SoapResp);
            //    outMessage = SoapResp;
            //}
            //catch (Exception ex)
            //{
            //   _logger.Error(ex + " \n" + ex.Message + "\n" + ex.InnerException + " \n" + ex.StackTrace);
            //}
            //return outMessage;
        }