xml文件 soap报文 提交到webservies




private async Task SendData(string message, string url)
{
using (HttpClient client = new HttpClient())
{
StringContent content = new StringContent(message, Encoding.UTF8);
HttpResponseMessage httpResponseMessage = await client.PostAsync(url, content);
HttpResponseMessage response = httpResponseMessage;
httpResponseMessage = null;
string text = await response.Content.ReadAsStringAsync();
string responseBody = text;
text = null;
Console.WriteLine(responseBody);
this.textBox1.Text = responseBody;
content = null;
response = null;
responseBody = null;
}
HttpClient client = null;
}

using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = "c:\\";
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
bool flag = openFileDialog.ShowDialog() == DialogResult.OK;
if (flag)
{
string fileName = openFileDialog.FileName;
string text = File.ReadAllText(fileName);
string text2 = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wms=\"http://wms.hzero.org\"><soapenv:Header/><soapenv:Body><wms:insertWorkOrder>";
string text3 = "  </wms:insertWorkOrder></soapenv:Body></soapenv:Envelope>";
this.SendData(text2 + text + text3, "http://10.60.35.11:32060/services/WorkOrderService");
}
}

posted @ 2024-11-21 10:57  网络来者  阅读(15)  评论(0)    收藏  举报