Web Services 4
Web Services 4
Web Services 4
Aim:- Develop client which consumes web services developed in different platforms.
Requirement:-
2. Netbeans 8.2
In this practical we are creating Web Service in Visual Studio and then we will consume it in NetBeans.
3. Now you can see, on the right side in Solution Explorer ->Service project is created.
4. Right click on Service->Add->New Item.
[WebMethod]
public double Add(double a, double b)
{
double sum = a + b;
return sum;
}
[WebMethod]
public double Mult(double a, double b)
{
double sum = a * b;
return sum;
}
After that press Ctrl+s to save the methods. We are creating two methods foe Web
Service.one for addition of two numbers and second for multiplication of two numbers.
7. Now Run the Project by clicking on Green arrow below the windows menu.
9. You can check services by clicking on Add or Mult option. But we don’t need this.
12. Don’t close the visual studio and browser, just minimize it else server will stop.
18. We can see that, we have got both the service methods i.e Add & Mult. Select atmost
one method.
19. Now create a JSP page. Right click on ServiceClient -> New -> Other.
20. Select Web in Categories section -> Select JSP and click on Next button.
21. Enter File Name ‘Add’ and click on Finish button.
23. Right click between body tag and select Call Web Service Operation.
24. Expand and select Add. After select, click on OK button.
27. Now open index.html file of ServiceClient project and replace the contents of body tag with
following code. Then save the code.
<form>
<input type="text" name="txt1" placeholder="Enter First Number:"><br><br>
<input type="text" name="txt2" placeholder="Enter Second Number:"><br><br>
<input type="submit" formaction="Add.jsp" value="Add numbers">
</form>
below.
29. Now enter two numbers and click on Add Numbers button.