问题
I have created a poc WCF service and i am able to call that service using SOAP UI or Postman. But for some project work, i need to parse the below soap security header
SOAP Header
<soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-5351BA8068B753C930158868612679914"><wsse:Username>test user</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">CS++k5OEqKsJByVPPmUqcBkAeoQ=</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">VK+Ilb/zy80lFbfHAAQupg==</wsse:Nonce><wsu:Created>2020-05-05T13:42:06.798Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
startup.cs file looks like below
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<ITestService, TestService>();
services.AddSoapServiceOperationTuner(new ServiceOperationTuner());
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Digest;
app.UseSoapEndpoint<ITestService>("/Service.svc", binding, SoapSerializer.DataContractSerializer);
}
}
ServiceOperationTuner.cs class has the code to get the HttpContext object as shown below. Here Tune menthod will be called for any request made to WCF service
public void Tune(HttpContext httpContext, object serviceInstance, OperationDescription operation)
{
}
httpContext object hold all the header details but not the soapenv:Header.
Can anyone help me to parse this soapenv:Header request in .Net core ? Thanks in advance
来源:https://stackoverflow.com/questions/61618341/how-to-read-parse-soap-header-request-in-wcf-service-created-in-net-core-3-1