0
想要与SOAP Web服务进行通信,我需要从wsdl文件创建SvcUtil.exe创建的C#类。.NET SOAP不会在请求头中发送BASIC认证
将下面的请求发送到安全服务器时(HTTPS with BASIC auth),我收到一个System.ServiceModel.Security.MessageSecurityException,并且通过让流量通过Burp代理检查HTTP请求时,我发现没有BASIC auth信息已通过。在C#代码中是否缺少SOAP请求,或者可能是BASIC认证不起作用的问题?
var binding = new WSHttpBinding();
binding.MessageEncoding = WSMessageEncoding.Mtom;
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.Name = "BasicAuthSecured";
SearchServicePortClient searchClient = new SearchServicePortClient(binding, new EndpointAddress("https://myUrl:Port/myService"));
searchClient.ClientCredentials.UserName.UserName = "username";
searchClient.ClientCredentials.UserName.Password = "pw";
query soap = new query();
//...
queryResponse response = searchClient.query(soap);
在此先感谢