title: Sending HTTP POST Request with XML to a web service and reading response data in C# for windows 8 phone
body: <p>I a newbie at windows 8 phone development. I want to send an aync HTTP POST Request to a PHP web service with some headers and XML in the request body.</p>
  
  <p>Also, I want to read the response sent back by the PHP web service.</p>
  
  <p>Please guide me, how can I achieve the above two stated things.</p>
  
  <hr>
  
  <p>what I have tried until now i am giving below</p>
  
  <pre><code>// Main begins program execution.
      public static void SendRequest()
      {
  
          HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.CreateHttp("http://mytestserver.com/Test.php");
          webRequest.Method = "POST";
          webRequest.ContentType = "text/xml";
          webRequest.Headers["SOURCE"] = "WinApp";
  
          var response = await httpRequest(webRequest);           
  
      }
  
      public static async Task&lt;string&gt; httpRequest(HttpWebRequest request)
      {
          string received;
  
          using (var response = (HttpWebResponse)(await Task&lt;WebResponse&gt;.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null)))
          {
              using (var responseStream = response.GetResponseStream())
              {
                  using (var sr = new StreamReader(responseStream))
                  {
  
                      received = await sr.ReadToEndAsync();
  
                      MessageBox.Show(received.ToString());
                  }
              }
          }
          return received;
      }
  </code></pre>
  
  <p>I am able to send the request using the above code. I just need to know that how I can send the XML in the request body to my web service.</p>