Wednesday, April 24, 2019

Creating SOAP Web service and Consuming it using Microsoft Visual Studio

Step 1:- Make sure to install Visual Studio from site belwo site vs_community__1147343234.1553667520.exe. Take Community Platform and install it. During installtion use .net Framework as core. If asked for restart at the end please do the same.
https://visualstudio.microsoft.com/downloads/
Step 2:- Follow the following Step to create SOAP Web service now.
Image1
Click on Create New project
Image2Image3Image4Image5Image6
Right click Project -->Add-->New Item-->Web Service ASMX
Image7
click Add Button and you are done with your Server side code ready for exposing your first SOAP WSDL Web Service.
What it do? It return you hello world text in soap.Lets check it!!!!
Image8
Run the Project using F5 button and you will be able to see the your web service on the page
Image9Image10
Click on HelloWorld
Image11
Click on Invoke button and your webservice will be invoked

Image12
Step 2:- Now let try to create our own Web service method. Lets call it as add which will take list as in input and will give addition of all the item in the list as result.

Image13
Now run the applciation using F5 and we will be able to see Add method on the screen.
Image14
Click on add method and you will be see it SOAP 1.1 and 1.2 version.
Image15
Step 3:- Now lets use this SOAP WSDL xml for generating client code to call this Add method and get the response.
For that right click on project-->"Add Service Reference"
Image16
click on go and you will be able to see all the Method exposed
Image17
Click Ok
We also need to add the webform page to our project i.e. WebForm.aspx to give the ui for calling the SOAP Web service.
Right Click Project -> Add --> new Item --> select Web Form

Image18
click Add

Image19
We need to add folloing code in its correspondign .cs file i.e. WebForm.aspx.cs

Image20Image21
Run the application by clicking F5

Image22
click on Button and see the result for the SOAP Web service ADD method which you had exposed.

Image23

No comments: