สร้างโปรเจ็กส์
File > New > Project…
เลือกโปรเจ็กส์แบบ Windows Classic Desktop > Windows Forms App (.NET Framework)
ตั้งชื่อโปรเจ็กส์ JackWinForm
เพิ่ม Web Services References
คลิกขวาที่ References > Add Service References…
ใส่ url ของ Web Services เช่น http://localhost:62668/MyWebService.asmx
กด Go
เลือก MyWebService > MyWebServiceSoap
ตั้งชื่อ MyServiceReference
ที่ Form1.cs
เพิ่ม Textbox, Button และ Label
เพิมอีเวนต์ให้ Button
1 2 3 4 5 6 7 8 |
private void button1_Click(object sender, EventArgs e) { double dFah = Double.Parse(textBox1.Text); MyServiceReference.MyWebServiceSoapClient soapClient = new MyServiceReference.MyWebServiceSoapClient(); double dCel = soapClient.ConvertTemperature(dFah); label1.Text = dCel.ToString(); } |