Question: How do you call a web service that uses XML Soap Envelope as Payload Body?
Login to See the Rest of the Answer
Answer: When working with Old Protocol like the Soap Web Service Protocol in Asp.Net Core 3.1, you can craft the Web Request just the same as would when calling an API, however, different Web Services require different Header Parameter to be passed, it would only help if you find out the requirement for making a Soap Web Request in Asp.Net Core 3.1. For example, code, see the code below:
var client = new RestClient("https://FirstLevelDomain/urlEndPoint.asmx?op=NameOfFunction");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "DomainNameWithoutHttps");
request.AddHeader("Content-Type", "text/xml");
request.AddHeader("charset", "utf-8");
request.AddHeader("SOAPAction", "\"http://DomainWithoutHttps/NameOfFunction\"");
request.AddParameter("text/xml", "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n <soap:Body>\r\n <NameOfFunction xmlns=\"http://domainName.com/\">\r\n <ParameterYouWantToPass>"+ paramValue + "</clientId>\r\n </soap:Body>\r\n</soap:Envelope>", ParameterType.RequestBody);
IRestResponse response = await client.ExecuteAsync(request);