HostelsClub provides you API Library and sample application in PHP to get connect with hostelsclub. But they don't have any API Library or application in ASP.NET. so if you want to do this, below sample can help you.
Through this sample you can PING the hostelsclub web-service search engine.
string targetUri = "http://www.hostelspoint.com/xml/xml.php";
System.Xml.XmlDocument reqDoc = new System.Xml.XmlDocument();
reqDoc.Load(Server.MapPath("~\\ping.xml"));//this is your xml file which u want to send to hostelsclub for ping
string formParameterName = "OTA_request";
string xmlData = reqDoc.InnerXml;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(targetUri);
string sendString = formParameterName + "=" + HttpUtility.UrlEncode(xmlData);
//string sendString = HttpUtility.UrlEncode(xmlData);
byte[] byteStream;
byteStream = System.Text.Encoding.UTF8.GetBytes(sendString);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteStream.LongLength;
using (Stream writer = request.GetRequestStream())
{
writer.Write(byteStream, 0, (int)request.ContentLength);
writer.Flush();
}
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
string respStr = "";
if (request.HaveResponse)
{
if (resp.StatusCode == HttpStatusCode.OK || resp.StatusCode == HttpStatusCode.Accepted)
{
StreamReader respReader = new StreamReader(resp.GetResponseStream());
respStr = respReader.ReadToEnd(); // get the xml result in the string object
XmlDocument doc = new XmlDocument();
doc.LoadXml(respStr);
Label1.Text = doc.InnerXml.ToString();
}
}
//===================PING.XML=======================
< ?xml version="1.0" encoding="UTF-8"? >
< OTA_PingRQ xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05OTA_PingRQ.xsd" TimeStamp="2009-12-28T11:43:43-05:00" Target="Test" Version="1.006" PrimaryLangID="en" EchoToken="1" >
< EchoData >Hello World< /EchoData >
< /OTA_PingRQ >
5 comments:
Above: Playrix's Homescapes is a new match-3 game.
Magnificent beat ! I would lke to apprentice while you amend your website,
how can i subscribe for a blog web site? The account helped
me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright
clear concept
What's up, I read your blog like every week.
Your story-telling style is awesome, keep doong what you're doing!
Incredible points. Outstanding arguments. Keeep up the amazing effort.
Используйте секретные, одноразовые
и многоразовые промокоды на пиццу Папа Джонс,
чтобы кушать больше, а платить
меньше. Просто воспользуйтесь кодовым словом или набором символов при
заказе выбранной продукции.
Активировав на сайте Папа Джонс промокод
в правом верхнем углу, вы сразу получите скидку или другое акционное предложение.
Главное знать, что именно нужно вводить.
Получите промокод папа джонс.
Post a Comment