Name:-Prakash kumawat
Class:-TYCS C
Roll no.:-9337
Practical No. 5
Aim: Create a web service as a Weather Information. Develop a client that consumes web
services developed in different platforms. (Java to .NET and .NET to Java)
Creating server-side application
Creating a web service with name [Link]
Code:
[Link]
package abc;
import [Link];
import [Link];
import [Link];
@WebService(serviceName =
"hello") public class hello {
@WebMethod(operationName = "getWeather")
public String getWeather(@WebParam(name = "city") String city) {
if([Link]("Panvel")){
return "Rain";
}
else if([Link]("Mumbai"))
{
return "No Rain";
}
else{
return "no city information";
}
}
}
Name:-Prakash kumawat
Class:-TYCS C
Roll no.:-9337
Testing the web service:-
Creating the client-side application:-
Steps:-
Step 1:-creating [Link] Web application(.NET framework) on visual studio.
Name:-Prakash kumawat
Class:-TYCS C
Roll no.:-9337
Step 2:-
Step 3:-Select Empty in this step
Name:-Prakash kumawat
Class:-TYCS C
Roll no.:-9337
Step 4:-Consuming the web service in this project. right click on the [Link] add then the
service reference.
Step 5:-Copy the link of WSDL file and paste here and select go and select the web service.
Name:-Prakash kumawat
Class:-TYCS C
Roll no.:-9337
Code:-
[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="application1.WebForm1" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
Enter City:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="getWeather" OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>
[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace application1
{
Name:-Prakash kumawat
Class:-TYCS C
Roll no.:-9337
public partial class WebForm1 : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
protected void Button1_Click(object sender, EventArgs e)
{
String city = [Link];
[Link] s1= new [Link]();
[Link]([Link](city));
}
}
}
Output: