WebService Example 2

Source: Internet
Author: User

Through the previous introduction, we should probably know how to write and call WebService. Next we will talk about how to use the service provided by WebService. Below is a piece of code, which is relatively simple:

Private void button#click (Object sender, system. eventargs E)
{
// Localhost. service1 A = new windowsapplication1.localhost. service1 ();
// A. helloworld ();
//
// D. url = "";
// D. getsiteadata ();
// D. helloworld ();
//
String strsearch = "123 ";
Servicea. service1 A = new servicea. service1 ();
Serviceb. service1 B = new serviceb. service1 ();
Iasyncresult AR1;
Iasyncresult AR2;
Dataset DS = new dataset ();
Xmlnode xmlnode1, xmlnode2;
Xmldatadocument XD = new xmldatadocument ();
Stringbuilder xmlstring1, xmlstring2;
// -- Simple asynchronous call
AR1 = A. begingetsiteadata (strsearch, null, null );
AR2 = B. begingetsiteadata (strsearch, null, null );
Xmlnode1 = A. endgetsiteadata (AR1 );
Xmlnode2 = B. endgetsiteadata (AR2 );
//----------
If (xmlnode1 = NULL & xmlnode2 = NULL )//--
Return;
Xmlstring1 = new stringbuilder (xmlnode1.outerxml );
Xmlstring2 = new stringbuilder (xmlnode2.outerxml );
Xmlstring1 = makenewxmlstring (xmlstring1, xmlstring2); // generate a new XML
If (xmlstring1.tostring (). Equals (""))
Return;
XD. loadxml (xmlstring1.tostring ());
DS. readxml (New xmlnodereader (xd ));
Datagrid1.datasource = Ds. Tables [0]
}
// Generate new XML
Public stringbuilder makenewxmlstring (stringbuilder str1, stringbuilder str2)
{
Str1 = str1.replace ("","");
Str2 = str2.replace ("","");
Str1.append (str2.tostring ());
Return str1;
}

This code is run in a Windows application. If it is an Asp.net application, you need to change it to the following:
Datagrid1.datasource = Ds. Tables [0]; followed by datagrid1.databand ();

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.