Reputation: 193
I'm new to Webservices and to ASP.Net..
I'm trying to retrieve the hotel in a certain city.. I used add service reference..
it didn't accept the XML schema (http://api.ean.com/ean-services/rs/hotel/v3?_wadl&type=xml&apiKey=[xxxYourAPIkeyxxx]
)
It accepted the Soap WSDL (http://api.ean.com/ean-services/rs/hotel/v3?_wadl&type=xml&apiKey=[xxxYourAPIkeyxxx]
)
After that I could access the classes but I have no Idea how can i return the list or provoke he method I tried to create a form and I've set the action to http://api.ean.com/ean-services/ws/hotel/v3/ as mentioned in the documentation
<form runat="server" action="http://api.ean.com/ean-services/ws/hotel/v3/"> <asp:Button ID="Button1" runat="server" onclick="Unnamed1_Click"/> </form>
this returns an XML with error 403 developer Inactive
I have added my IP address to the application in the EAN website
Please I need any help you can give me whether in tutorials , examples or some explanation
Upvotes: 1
Views: 2387
Reputation: 193
After adding a service reference I created a form and a button in my defualt.aspx
<form runat="server"> <asp:Button ID="button3" runat="server" OnClick="button3_Click" /> </form>
the button invokes the method button3_Click in the defualt.aspx.cs (ExpediaAPIShared is the name I gave the service when I added it)
ExpediaAPIShared.HotelServicesClient client = new HotelServicesClient(); ExpediaAPIShared.HotelListRequest hotelListRequest = new HotelListRequest(); ExpediaAPIShared.HotelList hotelList = new HotelList(); ExpediaAPIShared.HotelListResponse hotelListResponse = new HotelListResponse(); client.Open(); hotelListRequest.apiKey = "6ppdh333hagfauy5724hdggn";//use ur own key hotelListRequest.cid = 55505; //this is the CID for testing hotelListRequest.city = "Riyadh"; hotelListRequest.datelessSupplierSort = true; hotelListResponse = client.getList(hotelListRequest); hotelList = hotelListResponse.HotelList; for (int i = 0; i < hotelList.size; i++) { Response.Write(hotelList.HotelSummary[i].name); Response.Write("</br>"); }
I needed to initiate each type because if i didn't the value of the object will remain null and I won't be able to add any value to it's attribute.
This code will return only the names of hotels in Riyadh..
Upvotes: 1
Reputation: 6541
It is hard to answer your question without seeing the API documentation. It seems from your question that the Expedia API supports two ways of accessing it. One is through a SOAP call (where you do an Add Service Reference to a WSDL file), and one is through a form POST. You should use one or the other. Add Service Reference is probably easiest. Just look at the files that Add Svc Ref generated, there should be a class there whose name ends with "...Client". Just create an instance of that class, and it will have the methods for your service. There's a tutorial at http://www.telerik.com/help/wpf/consuming-data-wcf-service.html
Upvotes: 0