private void button1_Click(object sender, EventArgs e) { var client = new ServiceReference1.Service1Client(); var txt = client.GetData((int)numericUpDown1.Value); label1.Text = txt; }
private void button1_Click(object sender, EventArgs e) { if (int.TryParse(textBox1.Text, out var i)) { //调用WCF服务 var svc = new ServiceReference1.Service1Client(); var output = svc.GetData(i); txOutp.Text += output + "\r\n"; //复合数据调用 var output2 = svc.GetDataUsingDataContract(new CompositeType { BoolValue = true, StringValue = $"Current Time Is {DateTime.Now:hh:mm:ss}" });
private void button1_Click(object sender, EventArgs e) { string sUrlService = "http://127.0.0.1:8081/Service1"; BasicHttpBinding pBinding = new BasicHttpBinding(); EndpointAddress pEndpointAddress = new EndpointAddress(sUrlService); Service1Client pClient = new ServiceReference1.Service1Client( pBinding, pEndpointAddress); try { textBox1.Text = pClient.GetData((int)numericUpDown1.Value); } catch (Exception pE) { textBox1.Text = "[ERROR] " + pE.Message; } }