Wcf SMS集成web api通过c#net中的HTTP原始POST使用XML

Wcf SMS集成web api通过c#net中的HTTP原始POST使用XML,wcf,rest,c#-4.0,asp.net-web-api,sms-gateway,Wcf,Rest,C# 4.0,Asp.net Web Api,Sms Gateway,我需要集成发送短信api使用像这样的网址。但我得到的信息是XML格式不正确 http://<url>/action?application=msg&action=sendmsg&responsetype=xml 请建议如何解决。strong文本看起来只是打字错误 将>添加到前端api_键的末尾,平衡XML需求将起作用 <data> <phone> 1234567890 </phone> <api_key 12

我需要集成发送短信api使用像这样的网址。但我得到的信息是XML格式不正确

  http://<url>/action?application=msg&action=sendmsg&responsetype=xml 

请建议如何解决。strong文本

看起来只是打字错误

将>添加到前端api_键的末尾,平衡XML需求将起作用

<data>
   <phone> 1234567890 </phone>
  <api_key 1234567890 </api_key>
  <message_body> This is message text </message_body>
</data>
HttpWebRequest httpWReq =
    (HttpWebRequest)WebRequest.Create(@"http:\\domain.com\page.asp");

ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "username=user";
postData += "&password=pass";
byte[] data = encoding.GetBytes(postData);

httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;

using (Stream stream = httpWReq.GetRequestStream())
{
    stream.Write(data,0,data.Length);
}

HttpWebResponse response = (HttpWebResponse)HttpWReq.GetResponse();

string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();