Agenda:
- Creating a web service and client.
- Working with the client Proxy.
- Deploying a Web Service and configuring the client.
- Debugging and Exception Handling in Web Services.
Question: What are Web Services?
Answer: Just try with some google search about definition and you will get an answer and if you want know how to do it so here's the solution.
Creating a Web Service and Client
Task 1: Create a Web service Web site
- Click Start, point to All Programs, point to Microsoft Visual Studio 2008 or Later, and then click Microsoft Visual Studio.
If prompted to choose your default environment settings, select General Development Settings, and then click Start Visual Studio.
- On the File menu, point to New, and then click Web Site.
- In the New Web Site dialog box:
- In the Templates pane, click ASP.NET Web Service.
- In the Location drop-down box, type E:\Labfiles\CurrencyService.
- In the Language list, click the language of your choice (either Microsoft Visual Basic® or Microsoft Visual C#), and then click OK.
- In Solution Explorer, click the CurrencyService web site.
- If you are working with Visual C#, on the Website menu, click Add New Item. In the Add New Item dialog box:
- In the Templates pane, click Web Configuration File.
- In the Name text box, ensure that the name of the file to add is set to Web.config and then click Add.
Note that if you are working with Visual Basic the Web site will already contain a Web Configuration file, so this step is not necessary.
- In Solution Explorer, expand the App_Code folder, and then do one of the following:
- If you are working with Visual Basic, double-click the Service.vb file.
- If you are working with Visual C#, double-click the Service.cs file.
- In the WebService attribute, change the Namespace default value http://tempuri.org/ to http://www.adventure-works.com.
- Select the HelloWorld method and the WebMethod attribute, and then press DELETE.
- In Solution Explorer, right-click the App_Code folder, and then click Add Existing Item.
- In the Add Existing Item dialog box:
- If you are working with Visual Basic, browse to E:\Labfiles\Starter\VB, and then double-click the DataHelper.vb file.
- If you are working with Visual C#, browse to E:\Labfiles\Starter\CS, and then double-click the DataHelper.cs file.
- In Solution Explorer, double-click the Web.config file.
- Replace the <connectionStrings/> element with the following code:
- <connectionStrings>
- <add name="adventureworks" connectionString="Data Source=lon-dev-01;Initial Catalog=AdventureWorks;Integrated Security=True"/>
- </connectionStrings>
- In the Web.config file, select the <compilation> element and replace the value false with the value true.
This enables debugging for the Web service. If you omit this step, the Microsoft Visual Studio development environment will offer to make the change for you the first time you run the service using the debugger.
- In Solution Explorer:
- If you are working with Visual Basic, double-click the Service.vb file.
- If you are working with Visual C#, double-click the Service.cs file.
- Enter the following code inside the class definition after the constructor:
- If you are working with Visual Basic:
- <WebMethod()> _
- Public Function IntegerSum( _
- ByVal a As Integer, ByVal b As Integer) As Integer
- Return a + b
- End Function
- If you are working with Visual C#:
- [WebMethod]
- publicintIntegerSum(int a, int b)
- {
- return a + b;
- }
- If you are working with Visual Basic:
- Enter the following code inside the class definition:
- If you are working with Visual Basic:
- <WebMethod()> _
- Public Function CurrencyForCountry( _
- ByValcountryRegionCode As String) As String
- Return DataHelper.GetCurrencyForCountry(countryRegionCode)
- End Function
- If you are working with Visual C#:
- [WebMethod]
- public string CurrencyForCountry(string countryRegionCode)
- {
- returnDataHelper.GetCurrencyForCountry(
- countryRegionCode);
- }
- If you are working with Visual Basic:
- In the Solution Explorer, select the Service.asmx file.
- Press F5.
Microsoft Internet Explorer starts and displays a page containing information about the service. Use this page to test the Web service methods.
- Click the CurrencyForCountry link.
- In the CurrencyForCountry Test page, type US for the countryRegionCode and then click Invoke.
- Verify that a second Internet Explorer window opens, displaying the following XML text:
- <?xml version="1.0" encoding="utf-8" ?>
- <string xmlns="http://www.adventure-works.com">US Dollar</string>
- Click the CurrencyForCountry link.
- Close both Internet Explorer windows.

Hadshana KamalanathanPosted Jul 22, 2018, 1:42 AM
Good one..
SubashPosted Sep 15, 2016, 4:57 AM
Nice job
Humayun Kabir MamunPosted Feb 16, 2016, 9:04 AM
Nice...
Shubham KumarPosted Jan 8, 2016, 2:39 AM
suggestion appreciate
Yatendra SharmaPosted Jan 8, 2016, 2:32 AM
use screenshot for more efffective articles
Shubham KumarPosted Jan 6, 2016, 2:20 AM
thnx
Kumaresh RajalingamPosted Jan 5, 2016, 10:11 PM
Good one sir
Muhammad Aqib ShehzadPosted Jan 5, 2016, 7:40 AM
Good Share
Arul RPosted Jan 4, 2016, 10:32 AM
Nice share
Shubham KumarPosted Jan 4, 2016, 8:52 AM
thnx..
Ruchi MishraPosted Jan 4, 2016, 8:49 AM
Nice explain sir.
Ankit BansalPosted Jan 4, 2016, 6:22 AM
Nice one..
Shubham KumarPosted Jan 4, 2016, 12:48 AM
thankx...
Anurag SarkarPosted Jan 3, 2016, 10:41 PM
Good article thanks for sharing.
Pankaj Kumar ChoudharyPosted Jan 3, 2016, 12:53 PM
Nice Explain Sir.............