Part 2 Consuming a web service

preview_player
Показать описание
Link for code samples used in the demo

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Link for all dot net and sql server video tutorial playlists

Here are the steps to consume the web service that we have created in Part 1.

Step 2: Now we need to add a reference to web service. To achieve this
a) Right click on References folder in the CalculatorWebApplication project and select Add Service Reference option
b) In the Address textbox of the Add Service Reference window, type the web service address and click GO button. In the namespace textbox type CalculatorService and click OK.

Step 3: Right click on CalculatorWebApplication project in solution explorer and add new webform.

Step 3: Copy and paste the following HTML
Get the HTML for the page from my blog as youtube doesn't allows HTML in the description of the video.

Step 4: Copy and paste the following code in the code-behind file
protected void btnAdd_Click(object sender, EventArgs e)
{
CalculatorService.CalculatorWebServicesSoapClient client =
new CalculatorService.CalculatorWebServicesSoapClient();
int result = client.Add(Convert.ToInt32(txtFirstNumber.Text),
Convert.ToInt32(txtSecondNumber.Text));
lblResult.Text = result.ToString();
}

In an interview the interviewer may ask you the following questions related to consuming a web service.
1. What is WSDL and what is it's purpose
2. How is a proxy class generated
3. What is the use of a proxy class
4. What actually happens when a web service reference is added

The following 2 paragraphs should provide the answers for the above questions
Visual studio generates a proxy class using the WSDL (Web Service Description Language) document of the web service. The WSDL document formally defines a web service. It contains
1. All the methods that are exposed by the web service
2. The parameters and their types
3. The return types of the methods

This information is then used by visual studio to create the proxy class. The client application calls the proxy class method. The proxy class will then serialize the parameters, prepares a SOAP request message and sends it to the web service. The web service executes the method and returns a SOAP response message to the proxy. The proxy class will then deserialize the SOAP response message and hands it the client application. We don't have to serialize or deserialize dot net CLR objects to and from SOAP format. The proxy class takes care of serialization and deserialization and makes the life of a developer much easier.
Рекомендации по теме
Комментарии
Автор

After diligently watching your tutorials for 6 months, today I am a developer in a big company in my country. Thanks so much for impacting me with rare to find details.

maryakins
Автор

you are the best teacher on the planet....

TheImranbergi
Автор

You are a legend! The only person who actually explains this properly. THANK YOU THANK YOU THANK YOU

Rossvr
Автор

I almost never comment on youtube videos but I have to say this. If you are an accomplished programmer but new to web services this video and the others are GREAT!!! Straightforward with no bloat, so you can quickly get up to speed on understanding what is involved with web services. Tempo of instruction is perfect and explanations of what is actually going on is spot on. Thanks!

jefffinlay
Автор

I have read countless articles and chapters and even seen training videos and i still struggled to understand proxy classes and the other inner workings of web services.. But after watching this video, it all makes perfect sense. Thanks for this and your other videos and for the very thorough step by step code samples and explanations.!!

gqntexas
Автор

You are one of the best online instructors on the planet. I have loved every one of your presentations. Kudos! Bravo!

uchennanwosu
Автор

your web service tutorials are just amazing they got no match on the web, this helped me do my final year project with ease thanks for the great work

moforemmanuel
Автор

Thank you very much sir, wanted to learn Web services from almost an year, I'm Crystal Clear now, GOD Bless you Sir !!!!

mithunMADDY
Автор

You are the best teacher in my whole life.

DanGerouszaPoisonous
Автор

Great primer. I was asked to attempt to uplift 12+ year old SOAP app to VS2013. Having never worked with Visual Studio or SOAP, this helped orient me to how and what VS does. Thank you!

tadmacy
Автор

You are the first source of information when I need to code something new. I guess I should send you half of my

fabiofullin
Автор

All that I needed in two videos. Thank you!!!!

jelenanikolic
Автор

Such a smooth explanation of a complicated topic. Great!!!

deepakbhardwaj
Автор

you are a best teacher in the world love your videos

daviddonadze
Автор

Thanks for your video series. They are indeed great videos which jump to the core with enough explanation. Much appreciated.

mohsenhs
Автор

Talk about working on old technology, this really helped.

TMANTMAN-psnf
Автор

Your videos are so helpful that I am having fun learning .NET. Thanx a ton!!!

Seema
Автор

Excellent Video. Thank you for posting. You did a great job !

polczym
Автор

Excellent as usual. Thank you very much for your great work which is very helpful to the devs community. God bless you.

Ayubajbnabi
Автор

Amazing work. Thank you for clearly explaining the ins and outs.

nussberger