Exemplo n.º 1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            _step.Message.Payload = xmlSent.Text;
            _step.Sent = true;

            if (cbxNpu.Checked)
            {
                var newNpu = Messaging.createNpu(_step.Message.Operation);

                var n = Utils.SelectNode(_step.Message.xml, "npu");
                n.InnerText = newNpu;

                _step.Message.Payload = _step.Message.xml.OuterXml;
                xmlSent.Text = Utils.PrettyPrint(_step.Message.Payload);
            }

            ShowLoading.Show();

            var msgSent = Messaging.SendMsg(_step.Message, tbUrl.Text);

            MsgSent = msgSent;
            xmlReceived.Text = Utils.PrettyPrint(msgSent.Received);

            tabControl1.SelectedIndex = 1;

            ShowLoading.Hide();
        }
Exemplo n.º 2
0
 public MsgSentForm(MessageSent sent)
 {
     InitializeComponent();
     MsgSent = sent;
     btnSend.Enabled = false;
     xmlSent.Text = Utils.PrettyPrint(sent.Send);
     xmlReceived.Text = Utils.PrettyPrint(sent.Received);
 }
Exemplo n.º 3
0
        public void ProcessRequest(object args)
        {
            try
            {
                var msg = args as MessageInfo;
                var xml = msg.xml;

                XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
                nsmgr.AddNamespace("ptpSoapHeader", "urn://ptp.pt/SharedResources/SchemaDefinitions/EAIMessaging/SOAPHeader");
                nsmgr.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");

                var aux = xml.SelectSingleNode("//auxiliaryGroupInfo", nsmgr);

                var msgOut = _sample;

                if (msg.NPU != null)
                {
                    msgOut = msgOut.Replace("###NPU##", msg.NPU);
                }

                if (msg.CorrelationNPU != null)
                {
                    msgOut = msgOut.Replace("##CORR_NPU##", "<correlationNPU>" + msg.CorrelationNPU + "</correlationNPU>");
                }
                else
                {
                    msgOut = msgOut.Replace("##CORR_NPU##", "");
                }

                if (msg.ProcessId != null)
                {
                    msgOut = msgOut.Replace("##PROC_ID##", msg.ProcessId);
                }
                else
                {
                    msgOut = msgOut.Replace("##PROC_ID##", "");
                }

                msgOut = msgOut.Replace("##DATE##", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"));

                if (aux != null)
                    msgOut = msgOut.Replace("##AUX##", aux.OuterXml);

                var msgSent = new MessageSent();
                msgSent.Send = msgOut;
                CommunicationWS.SendMessage(msgSent, Configuration.UrlReturn, "http://telecom.pt/ptMsgInt/2009/12/16/in/pubMessage");

                var strNpu = msg.NPU == null ? "N/A" : msg.NPU;
                Logger.Log("#INFO# Send Signal, NPU: " + strNpu);
            }
            catch (Exception ex)
            {
                Logger.Exception(ex, "ProcessRequestSignal");
            }
        }
Exemplo n.º 4
0
        internal static MessageSent ReplyGPError(MessageInfo msg)
        {
            var e0 = Utils.GetResourceTextFile("GR_E0.xml");

            var npu = createNpu("GENREPIRTO", "0025");
            e0 = string.Format(e0, npu, msg.NPU);

            var msgSent = new MessageSent();
            msgSent.Msg = msg;
            msgSent.NPU = npu;
            msgSent.Date = DateTime.Now;
            msgSent.Send = e0;

            CommunicationWS.SendMessage(msgSent, Configuration.UrlReturn, "http://telecom.pt/ptMsgInt/2009/12/16/in/pubMsgReport");

            return msgSent;
        }
Exemplo n.º 5
0
        internal static MessageSent SendMsg(MessageInfo msg, string url = null)
        {
            if(url == null){
                url = CommunicationWS.GetUrl(msg.InterfaceToInvoke);
            }

            var soapEnv = Utils.GetResourceTextFile("soapEnv.xml");
            var bodyMsg = string.Format(soapEnv, msg.Payload);

            var messageSent = new MessageSent();

            messageSent.Date = DateTime.Now;
            messageSent.Msg = msg;
            messageSent.Send = bodyMsg;

            CommunicationWS.SendMessage(messageSent, url, CommunicationWS.GetSoapAction(msg.InterfaceToInvoke, msg.Operation));

            return messageSent;
        }
Exemplo n.º 6
0
        public static void SendMessage(MessageSent msg, string url, string soapAction)
        {
            try
            {
                var request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "POST";
                request.ContentType = "text/xml;charset=UTF-8";
                //request.UserAgent = "Jakarta Commons-HttpClient/3.1";
                //request.ContentLength = msg.Send.Length;
                request.Headers.Add("SOAPAction", soapAction);
                request.Accept = "text/xml";
                request.KeepAlive = true;

                var aStream = request.GetRequestStream();
                var aStreamWriter = new StreamWriter(aStream);

                aStreamWriter.Write(msg.Send);
                aStreamWriter.Close();

                WebResponse response = request.GetResponse();

                ValidateResponse(response, msg);
            }
            catch (Exception ex)
            {
                msg.Status = MessageStatusEnum.Fail;
                msg.Received = ex.Message + "\r\n" + ex.StackTrace;
                Logger.Exception(ex, "SendMessage");
            }
        }
Exemplo n.º 7
0
        private static void ValidateResponse(WebResponse response, MessageSent msg)
        {
            if (response == null)
            {
                msg.Received = "Unable to read response";
                msg.Status = MessageStatusEnum.Fail;
                return;
            }
            var reader = new StreamReader(response.GetResponseStream());

            var str = reader.ReadToEnd();

            str = cleanStream(str);

            msg.Received = str;

            reader.Close();

            var xml = new XmlDocument();
            xml.LoadXml(str);

            var eCode = xml.SelectSingleNode("//*[local-name()='eCode']");

            if (eCode == null || (eCode.InnerText != "22I0000" && eCode.InnerText != "I0"))
                msg.Status = MessageStatusEnum.Fail;
            else
                msg.Status = MessageStatusEnum.OK;
        }