示例#1
0
        private void SndSoapMessage()
        {
            string uri    = this.textBoxURI.Text;
            string action = this.textBoxAction.Text;

            string sndMsg = _ctrlSndSoap.GetXmlString();
            string rcvMsg = "";

            DateTime   dtB = DateTime.Now;
            SOAPSender s   = new SOAPSender(
                Program.Context.ConfigMgr.Config.GetWCFConfigFileNameWithFullPath(),
                Program.Context.Log);
            bool res = s.SendMessage(
                this.textBoxURI.Text.Trim(),    // Program.Context.ConfigMgr.Config.SOAPServiceURI,
                this.textBoxAction.Text.Trim(), //Program.Context.ConfigMgr.Config.SOAPAction,
                sndMsg, ref rcvMsg);
            DateTime dtE = DateTime.Now;

            TimeSpan ts = dtE.Subtract(dtB);

            this.labelSndSoapPerform.Text = ts.TotalMilliseconds.ToString() + " ms";

            if (res)
            {
                // for better display in web browser control
                _ctrlRcvSoap.Open("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + rcvMsg);
            }
            else
            {
                MessageBox.Show(this,
                                "Send SOAP message error. Please see log file for details.",
                                this.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void RunAll(int times)
        {
            if (times < 1)
            {
                return;
            }

            FileComboBoxItem i = _ctrlSampleMsg.GetSelectedItem();

            if (i == null)
            {
                return;
            }

            string sndSoap = "";
            string rcvSoap = "";

            HYS.IM.Messaging.Objects.Message rcvMsg = null;
            HYS.IM.Messaging.Objects.Message sndMsg =
                XObjectManager.CreateObject <HYS.IM.Messaging.Objects.Message>(i.FileContent);

            if (sndMsg == null)
            {
                MessageBox.Show(this,
                                "Deserialize XDS Gateway message failed. \r\n" +
                                "Please check whether the XML string conforms to XDS Gateway message schema.",
                                this.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            string     uri    = this.textBoxURI.Text;
            string     action = this.textBoxAction.Text;
            SOAPSender s      = new SOAPSender(
                Program.Context.ConfigMgr.Config.GetWCFConfigFileNameWithFullPath(),
                Program.Context.Log);

            bool            res    = false;
            List <TimeSpan> tsList = new List <TimeSpan>();

            for (int t = 0; t < times; t++)
            {
                DateTime dtB = DateTime.Now;
                if (_controler.GenerateSOAPMessage(sndMsg, out sndSoap))
                {
                    if (s.SendMessage(
                            this.textBoxURI.Text.Trim(),    // Program.Context.ConfigMgr.Config.SOAPServiceURI,
                            this.textBoxAction.Text.Trim(), //Program.Context.ConfigMgr.Config.SOAPAction,
                            sndSoap, ref rcvSoap))
                    {
                        res = _controler.GenerateXDSGWMessage(rcvSoap, out rcvMsg);
                        if (!res)
                        {
                            break;
                        }
                    }
                    else
                    {
                        res = false;
                        break;
                    }
                }
                else
                {
                    res = false;
                    break;
                }
                DateTime dtE = DateTime.Now;
                TimeSpan ts  = dtE.Subtract(dtB);
                tsList.Add(ts);
            }

            if (res)
            {
                double totalMs = 0;
                foreach (TimeSpan ts in tsList)
                {
                    totalMs += ts.TotalMilliseconds;
                }
                this.labelRunPerform.Text = (double)(totalMs / (double)times) + " ms";

                _ctrlSndMsg.Open("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + sndMsg.ToXMLString());
                _ctrlSndSoap.Open("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + sndSoap);
                _ctrlRcvSoap.Open("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + rcvSoap);
                _ctrlRcvMsg.Open("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + rcvMsg.ToXMLString());
            }
            else
            {
                MessageBox.Show(this,
                                "Transform or send message error. Please see log file for details.",
                                this.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }