,
Share this with your friends 
 

HOW TO CONSUME A WEB SERVICE

0 ratings Views 588 
Author: Daniel_7464bf92 (Daniel Odongo)  View Profile |  View other solutions by this author

Question / Problem


CONSUME WEB SERVICE IN VB.NET

Solution

2. CONSUMING THE WEB SERVICE
- Create a windows form application
- Insert a textbox, three labels and a button
- Add web reference, right click on the solution explorer, select add web service reference
- Insert the location of the web service
- Press ok
- Insert the following code in the button
try
{
//soap name in web.config file
var res = new WebService1SoapClient("WebService1Soap");
res.Open();

var inpt = res.ChequepointAccounts(this.textBox1.Text);

//assign account details inside an array
string str = "";
str += "<table width=100% border=1 bordercolor='black'>";
str += "<tr><td>Name:</td><td><small>" + inpt.accountvalues[0].name+"</td></tr>";
str += "<tr><td>Branch:</td><td>" + inpt.accountvalues[0].branch +"</td></tr>";
str += "<tr><td>Branch:</td><td>" + inpt.accountvalues[0].address +"</td></tr>";
this.webBrowser1.DocumentText = str;
}
catch (Exception)
{
throw;
}

- Run the project, insert a correct number and click the button
- Note that the report is displayed in a web browser.


Applies to

VB 2005

Rank It

Login to rank it

Report


Advertisement