Потребление веб-сервиса с превентивной аутентификацией
Hello, sorry for my translation, I hope you understand, at the moment I am making the consumption of a webservice from an application developed in c #. The consumption from the SoapUI program is achieved successfully, activating a preference that is called, preventive authentication, its user and password are configured in the tab called "Auth". However, when I try to send a header with the user and the password returns the error "(500) Internal error of the server", the webservice associates it with the project as a web reference, as recommended by one of the pages in which I found a solution .
Что я уже пробовал:
*До сих пор я связывал WS с проектом как ссылку на сервис и как веб-ссылку.
*Я добавил следующие строки кода, чтобы отправить в заголовок учетные данные и таким образом воссоздать превентивную аутентификацию.
string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(wsParams[0] + ":" + wsParams[1])); req.PreAuthenticate = true; req.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested; req.Headers.Add("Authorization", auth); WebResponse resp = req.GetResponse();
*Получив ответ (500), я попытался воссоздать с помощью SoapUI пользователя и пароль в заголовке, но безуспешно. Что подводит меня ко второму тесту кода.
*Попробуйте отправить аутентификацию с помощью свойства credentials из предыдущего кода, но таким же образом я получу ответ (500)
NetworkCredential networkCredential = new NetworkCredential(wsParams[0], wsParams[1]); req.Credentials = networkCredential; req.PreAuthenticate = true; WebResponse myWebResponse = req.GetResponse();
С этого момента я перепробовал почти все, но до сих пор не могу получить потребление ws по коду, я был бы очень признателен за идею о том, как я могу сделать потребление.
Быть внимательным