示例#1
0
        public static XElement Send(string hostNameorAddress, string relativeUri, YamahaAVLib.ENums.HttpMethod httpMethod, string requestBody)
        {
            string   result  = string.Empty;
            XElement xresult = null;

            try
            {
                HttpWebRequest request = Http.CreateRequest(hostNameorAddress, relativeUri, httpMethod);

                request = Http.WriteDataToRequest(request, requestBody);

                result = Http.GetResponse(request);

                xresult = XElement.Parse(result);
            }
            catch (System.Exception ex)
            {
                //throw;
            }

            return(xresult);
        }
示例#2
0
        /// <summary>
        /// This method creates HTTP request using Host Name or IP Address of the AV Unit, and relative location of the requesting resource.
        /// </summary>
        /// <param name="hostNameorAddress">Host Name or IP Address</param>
        /// <param name="relativeUri">relative location of the requesting resource</param>
        /// <param name="httpMethod">HTTP Method</param>
        /// <returns>HttpWebRequest</returns>
        public static HttpWebRequest CreateRequest(string hostNameorAddress, string relativeUri, YamahaAVLib.ENums.HttpMethod httpMethod)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("http://{0}/{1}", hostNameorAddress, relativeUri));

            request.UserAgent   = Atomics.UserAgent;
            request.ContentType = Atomics.ContentType;
            request.Method      = httpMethod.ToString();
            return(request);
        }