Windows C++我应该使用 WinHttp 库还是 MSXML 中的 XmlHttp?
一个相当简单的问题。我应该使用 WinHttp
库在我的 C++ 程序中发出 Web 服务请求,还是应该使用 msxml
库中的 IXmlHttpRequest
接口来发送网络服务请求?显然,与 IXmlHttpRequest
库相比,WinHttp
库提供了更精细的控制。但 XmlHttpRequest
对象是一个 w3.org
标准,理论上更具可移植性。
A rather simple question. Should I use the WinHttp
library to make a web service request in my C++ programs or should I use the IXmlHttpRequest
interface in the msxml
library to send web service requests? Obviously the WinHttp
library provides a lot more fine control compared to the IXmlHttpRequest
library. But the XmlHttpRequest
object is a w3.org
standard and in theory more portable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于您是通过安全通道(即 HTTPS)还是简单通道(即 HTTP)访问服务。
根据 MSDN (
http://msdn.microsoft.com/en-us/library/ms891732.aspx
),IXMLHttpRequest 仅支持 HTTP。但 WinInet API 相当旧,并且存在一些多线程问题(我认为 MSDN 上也有)...
因此,最好的选择是用于 HTTPS 和 HTTP 的 WinHTTP,否则使用旧的 IXMLHttpRequest。
注意: libcurl 和curpp(libcurl 的c++ 端口)也可以检查。有一篇旧帖子
http://stackoverflow.com/questions/1011339/how-do-you-make-a-http-request-with-c
It depends whether you are accessing the service on secure channel i.e. HTTPS or simple one i.e. HTTP.
As per MSDN (
http://msdn.microsoft.com/en-us/library/ms891732.aspx
), IXMLHttpRequest supports only HTTP.But WinInet API is quite old and have some multi-threading issues (I think its there on MSDN too)...
So the best bet is WinHTTP for HTTPS and HTTP, otherwise good old IXMLHttpRequest.
Note: libcurl and curlpp (c++ port of libcurl) is also there to check. There is an old post for this
http://stackoverflow.com/questions/1011339/how-do-you-make-a-http-request-with-c
对您的“简单问题”的简单回答:您应该使用您感觉最舒服并且最适合您的要求的东西。
您还可以考虑 http boost::asio 中的客户端。
Simple answer to your "simple question": You should use what you feel most comfortable in and what best fits to your requirements.
You could also consider the http client in boost::asio.