Hi @Виктор Белянкин, Welcome to Microsoft Q&A,
To resolve the error "A request that does not have a valid action parameter cannot be processed. Specify a valid SOAP action." in your SOAP request, you need to ensure that the SOAPAction
header is correctly set and that the SOAP request body matches the expected structure of the web service.
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
public class Soap
{
public async static Task CallWebService()
{
var _url = "http://192.168.88.51:80/reportserver/ReportService2010.asmx";
var _action = "http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/DisableSubscription";
string subscriptionID = "f7c5fe39-33b2-44be-82e2-f14fa91b79a4";
string _soap = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\""
+ " xmlns:ns2=\"http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer\""
+ " xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\""
+ " xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">"
+ "<SOAP-ENV:Body>"
+ "<ns2:DisableSubscription>"
+ " <ns2:SubscriptionID>" + subscriptionID + "</ns2:SubscriptionID>"
+ "</ns2:DisableSubscription>"
+ "</SOAP-ENV:Body>"
+ "</SOAP-ENV:Envelope>";
string response = await CreateWebRequest(_url, _action, _soap);
}
private async static Task<string> CreateWebRequest(string url, string action, string soap)
{
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("login", "pass");
var handler = new HttpClientHandler { Credentials = credentials };
HttpClient client = new(handler);
Console.WriteLine($"SOAP Request:\n{soap}");
using HttpContent content = new StringContent(soap, Encoding.UTF8, "text/xml");
using HttpRequestMessage request = new(HttpMethod.Post, url);
request.Content = content;
request.Headers.Add("SOAPAction", action);
using HttpResponseMessage response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine($"SOAP Response:\n{result}");
return result;
}
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.