Esempio n. 1
0
        private void cmboBoxServiceList_SelectedIndexChanged(object sender, EventArgs e)
        {
            serviceDescriptionPanel.Controls.Clear();
            configurationServicesService service = this._services[(string)cmboBoxServiceList.SelectedItem];
            Label l = new Label();

            l.Width  = 216;
            l.Height = 58;
            l.Text   = service.service_description;
            serviceDescriptionPanel.Controls.Add(l);

            this._methods.Clear();
            cmboBoxMethodList.SelectedIndex = -1;
            cmboBoxMethodList.Items.Clear();
            if (this._services.ContainsKey((string)cmboBoxServiceList.SelectedItem))
            {
                service = this._services[(string)cmboBoxServiceList.SelectedItem];
                foreach (configurationServicesServiceMethod method in service.method)
                {
                    cmboBoxMethodList.Items.Add(method.method_name);
                    this._methods.Add(method.method_name, method);
                }
            }
        }
Esempio n. 2
0
        private void btnEngageService_Click(object sender, EventArgs e)
        {
            tvResults.Nodes.Clear();
            try
            {
                string URL       = "";
                string nameSpace = "";
                string method    = "";
                Dictionary <string, string> parameters = new Dictionary <string, string>();

                if (this._services.ContainsKey((string)cmboBoxServiceList.SelectedItem))
                {
                    configurationServicesService service = this._services[(string)cmboBoxServiceList.SelectedItem];
                    nameSpace = service.target_namespace;
                    URL       = service.service_URL;
                }

                if (this._methods.ContainsKey((string)cmboBoxMethodList.SelectedItem))
                {
                    method = (string)cmboBoxMethodList.SelectedItem;
                }

                foreach (KeyValuePair <configurationServicesServiceMethodParameter, TextBox> prms in this._parameters)
                {
                    String tempValue = (String)prms.Value.Text;
                    String tempName  = (String)prms.Value.Name;

                    switch (prms.Key.type)
                    {
                    case ("string"):
                        //Nothing to do here
                        break;

                    case ("boolean"):
                        bool b = new bool();
                        if (!Boolean.TryParse(tempValue, out b))
                        {
                            MessageBox.Show("Failed to read value for parameter " + tempName + " value should be either true or false.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        break;

                    case ("int"):
                        Int64 i = new Int64();
                        if (!Int64.TryParse(tempValue, out i))
                        {
                            MessageBox.Show("Failed to read value for parameter " + tempName + " value should be an Integer.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        break;

                    case ("double"):
                        Double d = new Double();
                        if (!Double.TryParse(tempValue, out d))
                        {
                            MessageBox.Show("Failed to read value for parameter " + tempName + " value should be a Double.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        break;

                    default:
                        //Unknown type no additional validation done
                        break;
                    }
                    parameters.Add(tempName, tempValue);
                }
                SoapRequest soapRequest = new SoapRequest(URL, nameSpace, method, parameters);
                try
                {
                    string result = soapRequest.CallWebService();
                    txtResult.Text = result;
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(result);

                    TreeNode newNode = CreateNode(doc.SelectSingleNode("//*[local-name()='Body']"));
                    tvResults.Nodes.Add(newNode);
                    tvResults.ExpandAll();
                    tvResults.SelectedNode = newNode;
                }
                catch (WebException ex)
                {
                    MessageBox.Show("Request returned error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error handling request: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }