迁移调用webservice的.net wcf项目到.net6,由于转义字符&导致接口不通

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

迁移调用webservice的.net wcf项目到.net6,由于转义字符&导致接口不通

//迁移调用webservice的.net wcf项目到.net6,由于webservice地址带转义字符例如&导致接口不通




private void TestWs()
{
//<?xml version=\"1.0\" encoding=\"utf-8\"?>
string xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:asi=\"http://siebel.com/asi/\" ><soapenv:Header><UsernameToken xmlns=\"http://siebel.com/webservices\">LIULL113650</UsernameToken><PasswordText xmlns=\"http://siebel.com/webservices\">LIULL113650</PasswordText></soapenv:Header><soapenv:Body><asi:Hans_spcAccount_spcInfo_spcQuery_spcWF><SearchExpr>[Account.Id]=&apos;1-F188GK&apos;</SearchExpr></asi:Hans_spcAccount_spcInfo_spcQuery_spcWF></soapenv:Body></soapenv:Envelope>";
HttpContent content = new StringContent(xml, Encoding.UTF8, "text/xml");
//content.Headers.Add("SOAPAction", "http://tempuri.org/LIS.WS.DHCLISService.GetData");
//content.Headers.Add("UsernameToken", "LIULL113650");
//content.Headers.Add("PasswordText", "LIULL113650");
string result;
using (HttpClient client = new HttpClient())
using (var response = client.PostAsync(@"http://172.17.253.70:8080/eai_chs/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&WSSOAP=1", content))
{
	result = response.Result.Content.ReadAsStringAsync().Result;
	//创建一个xml文档
	XmlDocument xmlDoc = new XmlDocument();
	//为文档导入数据
	xmlDoc.LoadXml(result);
	result = xmlDoc.InnerText;
}
}


迁移调用webservice的.net wcf项目到.net6,由于转义字符&amp;导致接口不通

//迁移调用webservice的.net wcf项目到.net6,由于webservice地址带转义字符例如&amp;导致接口不通private void TestWs(){//<?xml version=\...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息