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);
在此先感謝