How to call HTTPS web service method from a .net console application?

女生的网名这么多〃 提交于 2020-01-04 05:35:17

问题


I have an ASP.net web application. It sits at https://www.example.com/Private.

I would like to create a .net console application that calls a web method on my ASP.net web application at https://www.example.com/Private/DataCall.

How do I program my .net console application to securely call the web method over HTTPS?

I have done this before in plain HTTP, but for this application, secure communication is essential.


回答1:


Uri uri = new Uri(url);
WebRequest webRequest = WebRequest.Create(uri);   
ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, ssl) => true;
WebResponse webResponse = webRequest.GetResponse();
ReadFrom(webResponse.GetResponseStream());

How do I use WebRequest to access an SSL encrypted site using https?



来源:https://stackoverflow.com/questions/8247695/how-to-call-https-web-service-method-from-a-net-console-application

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