Professional Documents
Culture Documents
Step (1) : Select File -> New -> Web Site in Visual
Studio, and then select ASP.NET Web Service.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
namespace StockService
{
// <summary>
// Summary description for Service1
// <summary>
[WebService(Namespace = "http://tempuri.o
[WebServiceBinding(ConformsTo = WsiProfil
[ToolboxItem(false)]
Step (6) : Change the code behind file to add the two
dimensional array of strings for stock symbol, name
and price and two web methods for getting the stock
information.
using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
[WebService(Namespace = "http://tempuri.org/
[WebServiceBinding(ConformsTo = WsiProfiles
string[,] stocks =
{
{"RELIND", "Reliance Industries", "106
{"ICICI", "ICICI Bank", "911.55"},
{"JSW", "JSW Steel", "1201.25"},
{"WIPRO", "Wipro Limited", "1194.65"
{"SATYAM", "Satyam Computers", "91.10"
};
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public double GetPrice(string symbol)
{
//it takes the symbol as parameter and
for (int i = 0; i < stocks.GetLength
{
if (String.Compare(symbol, stocks
return Convert.ToDouble(stocks[i,
}
return 0;
}
[WebMethod]
public string GetName(string symbol)
{
// It takes the symbol as parameter an
// returns name of the stock
for (int i = 0; i < stocks.GetLength
{
if (String.Compare(symbol, stocks
return stocks[i, 1];
}
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server">
<title>
Untitled Page
</title>
</head>
<body>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace wsclient
{
public partial class _Default : System.
{
protected void Page_Load(object sender
{
if (!IsPostBack)
{
lblmessage.Text = "First Loading
}
else
{
lblmessage.Text = "PostBack at:
}
}
using localhost;
Advertisements
Annual Membership
Enjoy unlimited access on 5500+
Hand Picked Quality Video Courses
✓ Subscribe Now