private static ResponseContent CreateRequest(string pswsServiceUri, string cmdletCommand, NetworkCredential credential, NameValueCollection headersTobeAdd, out string requestXml, out string responseXml)
        {
            string requestUri = string.Format("{0}/{1}/{2}", pswsServiceUri, "Service.svc", "CommandInvocations");

            requestXml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n                    <entry xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\"\r\n                        xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"\r\n                        xmlns=\"http://www.w3.org/2005/Atom\">\r\n                        <content type=\"application/xml\">\r\n                            <m:properties>\r\n                                <d:Command>{0}</d:Command>\r\n                                <d:OutputFormat>{1}</d:OutputFormat>\r\n                                <d:WaitMsec m:type=\"Edm.Int32\">{2}</d:WaitMsec>\r\n                            </m:properties>\r\n                        </content>\r\n                    </entry>", SecurityElement.Escape(cmdletCommand), "ExchangeXml", 30000);
            NameValueCollection headers = CommandInvocation.PrepareRequestHeaders(requestUri, headersTobeAdd);

            ExTraceGlobals.InstrumentationTracer.Information <string>(0L, "CommandINvocation request xml : {0}", requestXml);
            ExTraceGlobals.InstrumentationTracer.Information <string>(0L, "CommandINvocation request header : {0}", string.Join(";", from string key in headers
                                                                                                                                select string.Format("{0}={1}", key, headers[key])));
            WebResponse     webResponse = null;
            ResponseContent response;

            try
            {
                webResponse = CommandInvocation.GetRequestSender().SendRequest(requestUri, credential, "POST", 600000, true, "application/atom+xml", headers, requestXml);
                response    = CommandInvocation.GetResponse(webResponse, out responseXml);
            }
            finally
            {
                if (webResponse != null)
                {
                    ((IDisposable)webResponse).Dispose();
                }
            }
            return(response);
        }
        private static ResponseContent ResumeRequest(string pswsServiceUri, string requrestGuid, NetworkCredential credential, NameValueCollection headersTobeAdd, out string responseXml)
        {
            string requestUri = string.Format("{0}/{1}/{2}(guid'{3}')", new object[]
            {
                pswsServiceUri,
                "Service.svc",
                "CommandInvocations",
                requrestGuid
            });
            NameValueCollection headers     = CommandInvocation.PrepareRequestHeaders(requestUri, headersTobeAdd);
            WebResponse         webResponse = null;
            ResponseContent     response;

            try
            {
                webResponse = CommandInvocation.GetRequestSender().SendRequest(requestUri, credential, "GET", 600000, true, "application/atom+xml", headers, null);
                response    = CommandInvocation.GetResponse(webResponse, out responseXml);
            }
            finally
            {
                if (webResponse != null)
                {
                    ((IDisposable)webResponse).Dispose();
                }
            }
            return(response);
        }