I’m writing a windows application which intern talks to a web interface
exposed at http://194.224.184.162/barceloDS/interface/xml . Now my problem
is, this exposed interface will accept the XML String as parameter and
returns data in XML Format. You can find the example of the XML Input, at
http://194.224.184.162/barceloDS/interface/example, which explains in detail
about the input XML String.
I’m trying to execute the following code, which returning me null text,
instead of some response. Correct me where I’m mistaken.
string GetResp()
{
// This is the XML Input String to the exposed XML Interface
string strReq = @"<?xml version=""1.0"" encoding=""UTF-8""
?><barceloDS_re quests><request type=""availabi lity list"" id=""1"">
<session_id></session_id> <language_code> ING</language_code> <agency>
<primary>888</primary> <secondary>88 </secondary> <detail>888</detail>
<branch>1</branch> </agency> <contract></contract>
<check_in_date> 20060801</check_in_date>
<check_out_date >20060803</check_out_date> <location>
<destination_co de>PMI</destination_cod e> <zone_code></zone_code> </location>
<establishmen t> <code></code> <category></category> </establishment>
<board_type_cod e></board_type_code > <occupancy> <adults>2</adults>
<children>1</children> <rooms>1</rooms> </occupancy> </request>
</barceloDS_reque sts>";
HttpWebRequest hwrRequest = (HttpWebRequest )
HttpWebRequest. Create("http://194.224.184.162/barceloDS/interface/xml");
hwrRequest.Meth od="POST";
hwrRequest.Cont entType = "text/xml";
UTF8Encoding encoding = new UTF8Encoding();
byte[] postBytes = encoding.GetByt es(strReq);
hwrRequest.Cont entLength=postB ytes.Length;
Stream postStream = hwrRequest.GetR equestStream();
postStream.Writ e(postBytes,0,p ostBytes.Length );
postStream.Clos e();
HttpWebResponse hwrResponse = (HttpWebRespons e) hwrRequest.GetR esponse();
Stream responseStream = hwrResponse.Get ResponseStream( );
XmlTextReader xtrSmp = new XmlTextReader(r esponseStream);
string strXm = xtrSmp.ReadInne rXml();
xtrSmp.Close();
hwrResponse.Clo se();
return strXm;
}
Regards,
--
Every thing is perfect, as long as you share!!!
Comment