-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotels.aspx.cs
61 lines (52 loc) · 2.04 KB
/
hotels.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HotelService;
using System.ServiceModel;
public partial class Hotels : System.Web.UI.Page
{
HotelsSoap soap;
protected void Page_Load(object sender, EventArgs e)
{
//Define the Soap Client
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://ws-design.idevdesign.net/hotels.asmx");
soap = new HotelsSoapClient(binding, address);
//Get Hotel Data
GetHotelData();
}
private void GetHotelData()
{
//Define Credentials
HotelCredentials credentials = new HotelCredentials();
credentials.username = "aeTraining";
credentials.password = "ZZZ";
//Define Request parameters
GetHotelRequest req = new GetHotelRequest();
req.HotelCredentials = credentials;
req.hotelId = 105304;
//Define a Hotel object
Hotel hotel = new Hotel();
//Get Response in the Hotel Object
GetHotelResponse response = new GetHotelResponse();
response = soap.GetHotel(req);
hotel = response.GetHotelResult;
if (hotel != null)
{
//Bind Data to controls
lblHotelId.Text = "Hotel ID: " + hotel.HotelID.ToString();
lblHotelName.Text = "Hotel Name: " + (string.IsNullOrEmpty(hotel.Name) ? string.Empty : hotel.Name);
lblAirportCode.Text = "Hotel AirportCode: " + hotel.AirportCode.ToString();
lblAddress.Text = "Hotel Address: " + (string.IsNullOrEmpty(hotel.Address1) ? string.Empty : hotel.Address1)
+ "<br />" + (string.IsNullOrEmpty(hotel.Address2) ? string.Empty : hotel.Address2)
+ "<br />" + (string.IsNullOrEmpty(hotel.Address3) ? string.Empty : hotel.Address3);
}
}
}