在Windows 8应用程序中使用休息服务的任何示例方法。请告诉我可能的链接。
答案 0 :(得分:4)
试试这个
using System.IO;
using System.Net.Http;
using System.Text;
var objHttpClient = new HttpClient();
var formParameters = "<details><id>1</id><name>test</name></details>");
var objHttpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "http://example.com/page");
objHttpRequestMessage.Content = new StreamContent(new MemoryStream(Encoding.UTF8.GetBytes(formParameters)));
objHttpRequestMessage.Content.Headers.Add("Content-Type", "text/xml");
var result = await objHttpClient.SendAsync(objHttpRequestMessage);
答案 1 :(得分:2)
使用System.Net.Http.StringContent课怎么样?
using System.Net.Http;
using System.Text;
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
var contentString = "<details><id>1</id><name>test</name></details>";
var httpClient = new HttpClient();
var httpRequestMessage = new HttpRequestMessage(
HttpMethod.Post,
"http://example.com/page");
httpRequestMessage.Content = new StringContent(
contentString,
Encoding.UTF8,
"text/xml");
var result = await httpClient.SendAsync(httpRequestMessage);
}