Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

1. HTTP RAW POST

C#
using System;
using System.IO;
using System.Net;

class MainClass
{
    public static void Main(string[] args)
    {
        string xmlMessage = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<OTA_HotelAvailNotifRQ>
    ...
</OTA_HotelAvailNotigRQ>";
        string url = "https://extranet.hotel-spider.ch/ota/OTA_HotelAvailNotif/2014A";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

        byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(xmlMessage);
        request.Method = "POST";
        request.ContentType = "text/xml;charset=utf-8";
        request.ContentLength = requestBytes.Length;
        Stream requestStream = request.GetRequestStream();
        requestStream.Write(requestBytes, 0, requestBytes.Length);
        requestStream.Close();

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        StreamReader respStream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);
        string receivedResponse = respStream.ReadToEnd();
        Console.WriteLine(receivedResponse);
        respStream.Close();
        response.Close();
    }
}
  • No labels