添加成功后, 会显示服务详细
option.RequestDataStr = GetHttpRequestXml(strXmlBody);
// 创建一个 HttpClient 对象
using (HttpClient client = new HttpClient())
{
// 创建一个 StringContent 对象,将 SOAP 请求转换为字符串
StringContent content = new StringContent(option.RequestDataStr, System.Text.Encoding.UTF8, "text/xml");
// 添加 SOAPAction 头信息
client.DefaultRequestHeaders.Add("SOAPAction", soapAction);
// 发送 POST 请求,并获取响应
HttpResponseMessage response = client.PostAsync(option.RequestUrl, content).ConfigureAwait(false).GetAwaiter().GetResult();
// 读取响应的内容
string responseContent = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
return responseContent;
}
//获取到xml后, 反解析xml
//Envelope 是根据xml自动生成的model
using (StringReader sr = new StringReader(responseStr))
{
XmlSerializer serializer = new XmlSerializer(typeof(Envelope));
var response = (serializer.Deserialize(sr) as Envelope).Body;
}
使用postmen或者SoapUI获取返回的xml,然后复制xml字符串,之后,点击编辑->选择性粘贴->将XML复制为类