Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/03/2018, 23:46
Avatar de luisvasquez
luisvasquez
 
Fecha de Ingreso: diciembre-2003
Ubicación: Venezuela
Mensajes: 879
Antigüedad: 20 años, 5 meses
Puntos: 6
Variable enviando POST a un web service

Buenas noches!

Necesito ayuda descifrando un código c# para hacer la función en otro lenguaje por requerimientos del cliente. No conozco nada de C# pero tal vez para los expertos mi pregunta es muy sencilla:

Tengo un código que envía un xml a un web service para realizar una solicitud. No he podido averiguar cual es el nombre de la variable que debe ser enviada al web service. El problema es que no tenemos la documentación de este Web service pero tenemos el codigo en #C.

Código:
string v_strURL = Helper.URL_DETAIL_HOTEL.ToString(); // Url del web service

            strXML = "<?xml version='1.0' encoding='utf-8'?>";
            strXML += "<GetHotelDetailRequest user='raymundo' password='123456'>";
            strXML += "<Language>es</Language>";
            strXML += "<DestinationCode>CUN</DestinationCode>";
            strXML += "<Broker>Hotelbeds</Broker>";
            strXML += "<HotelCode>4894</HotelCode>";
            strXML += "<HotelName>CasaMagna+Marriott+Cancun+Resort</HotelName>";
            strXML += "<AvailToken>1HdC5yhCq7GbGe2NtxA8Zwiy</AvailToken>";
            strXML += "</GetHotelDetailRequest>";

            XmlDocument XMLResponse = null;
            XmlDocument xmldoc = new XmlDocument();

            //Declare an HTTP-specific implementation of the WebRequest class.
            HttpWebRequest objHttpWebRequest;

            //Declare an HTTP-specific implementation of the WebResponse class
            HttpWebResponse objHttpWebResponse = null;

            //Declare a generic view of a sequence of bytes
            Stream objRequestStream = null;
            Stream objResponseStream = null;
            DataSet datasetD = new DataSet();
            DataTable tblHotelData = new DataTable();

            //Declare XMLReader
            XmlTextReader objXMLReader;

            objHttpWebRequest = (HttpWebRequest)WebRequest.Create(v_strURL);

            try  {

                //Set HttpWebRequest properties
                byte[] bytes;
                bytes = System.Text.Encoding.UTF8.GetBytes(strXML);
                objHttpWebRequest.Method = "POST";
                objHttpWebRequest.ContentLength = bytes.Length;
                objHttpWebRequest.ContentType = "application/x-www-form-urlencoded";

                //Get Stream object 
                objRequestStream = objHttpWebRequest.GetRequestStream();

                //Writes a sequence of bytes to the current stream 
                objRequestStream.Write(bytes, 0, bytes.Length);

                //Close stream
                objRequestStream.Close();

                //---------- End HttpRequest

                //Sends the HttpWebRequest, and waits for a response.
                objHttpWebResponse = (HttpWebResponse)objHttpWebRequest.GetResponse();

               }
Lo que hace este código es construir un XML y enviarlo vía POST a la URL. Pregunta: ¿Cual es el nombre de la variable que se envía?

Mil gracias por su ayuda,