How to add soap basic auth request to WSDL

只愿长相守 提交于 2020-01-02 13:22:30

问题


How can I had soap AUTH BASIC auth to a WSDL, so who ever reads the WSDL knows I require that operation for a specific method ?


回答1:


Using the example bellow I have managed to pass the SOAP basic autentication to the php webservice on the other end. The PHP.net/Soapclient has a simple working example, but in csharp I found this link to be a solution to my problem.

link

Michaelis.MockService is the Webservice library extracted you may see an example on how to do this in: link Mono project website.

Michaelis.MockService service = new Michaelis.MockService();

// Create the network credentials and assign
// them to the service credentials
NetworkCredential netCredential = new NetworkCredential(“Inigo.Montoya”, “Ykmfptd”);
Uri uri = new Uri(service.Url);
ICredentials credentials = netCredential.GetCredential(uri, “Basic”);
service.Credentials = credentials;

// Be sure to set PreAuthenticate to true or else
// authentication will not be sent.
service.PreAuthenticate = true;

// Make the web service call.
service.Method();



回答2:


There is no way to specify this, as far as I know.



来源:https://stackoverflow.com/questions/4948074/how-to-add-soap-basic-auth-request-to-wsdl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!