Then write the Windows client and Web client to consume the service

Source: Internet
Author: User
Tags tostring
The web|window| client is designed to embody the xmlwebservice heterogeneous platform, independent of the system and device independent of the consumer's application type.
Shows students how to use C # to write a Windows program to consume the service:

The code is simple, just add the following lines:
private void Button1_Click (object sender, System.EventArgs e)
{
Get.service1 aa=new WS03. Get.service1 ();
String Score=aa. Getscore (ComboBox1.SelectedItem.ToString (), comboBox2.SelectedItem.ToString ()). ToString ();
Label3. text= "Student" +combobox1.selecteditem.tostring () + "" +combobox2.selecteditem.tostring () + "The result is:" +score;
}

private void Button2_Click (object sender, System.EventArgs e)
{
Get.service1 aa=new WS03. Get.service1 ();
String Average=aa. Getaverage (ComboBox1.SelectedItem.ToString ()). ToString ();
Label4. text= "Student" +combobox1.selecteditem.tostring () + "The average score is:" +average;
}

private void Button3_Click (object sender, System.EventArgs e)
{
Get.service1 aa=new WS03. Get.service1 ();
String Order=aa. GetOrder (ComboBox1.SelectedItem.ToString ()). ToString ();
Label5. text= "Student" +combobox1.selecteditem.tostring () + "The ranking is:" +order+ "name";
}


Then use vb.net to write a asp.net program to invoke the service:

The code is also very simple:
Private Sub button1_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
Dim AA as New [get]. Service1
Label1.Text = AA. Getscore (DropDownList1.SelectedItem.Text, DropDownList2.SelectedItem.Text)
End Sub

Private Sub button2_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button2.click
Dim AA as New [get]. Service1
Label2.Text = AA. Getaverage (DropDownList1.SelectedItem.Text)
End Sub

Private Sub button3_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button3.click
Dim AA as New [get]. Service1
Label3.text = AA. GetOrder (DropDownList1.SelectedItem.Text)
End Sub
Of course, in both programs, don't forget to add the Web reference and generate the SOAP proxy locally, but a lot of work is done by the Vs.net IDE.
If you're using WebMatrix to write a asp.net consumer Web service, there's a job you need to do for yourself, which you'll talk about next time.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.