在 C++ 和 Windows 中使用 XmlRpc
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/68144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using XmlRpc in C++ and Windows
提问by Tim Cooper
I need to use XmlRpc in C++ on a Windows platform. Despite the fact that my friends assure me that XmlRpc is a "widely available standard technology", there are not many libraries available for it. In fact I only found one library to do this on Windows, (plus another one that claims "you'll have to do a lot of work to get this to compile on Windows). The library I found was Chris Morley's "XmlRpc++". However, it doesn't have support for SSL.
我需要在 Windows 平台上的 C++ 中使用 XmlRpc。尽管我的朋友向我保证 XmlRpc 是一种“广泛可用的标准技术”,但可用的库并不多。事实上,我只在 Windows 上找到了一个库,(加上另一个声称“你必须做很多工作才能在 Windows 上编译它)。我找到的库是 Chris Morley 的“XmlRpc++”。但是,它不支持 SSL。
My question therefore is: what library should I be using?
因此,我的问题是:我应该使用什么库?
回答by Tim Cooper
I've written my own C++ library. It's available at sourceforge: xmlrpcc4win
我已经编写了自己的 C++ 库。它在 sourceforge 上可用: xmlrpcc4win
The reason I wrote it rather than using Chris Morley's was that:
我写它而不是使用 Chris Morley 的原因是:
- The Windows "wininet.lib" library gives you all the functionality for handling Http requests, so I'd rather use that. As a result, I only needed 1700 LOC.
- "wininet.lib", and therefore my implementation, supports HTTPS
- Chris Morley's use of STL containers was quite inefficient (Chris, mail me if you read this).
- Windows“wininet.lib”库为您提供了处理 Http 请求的所有功能,所以我宁愿使用它。结果,我只需要 1700 LOC。
- “wininet.lib”,因此我的实现,支持HTTPS
- Chris Morley 对 STL 容器的使用效率很低(Chris,如果你读到这个,请给我发邮件)。
回答by Tim Cooper
Until I wrote my own library, (see above) here was my answer:
在我编写自己的库之前,(见上文)这是我的答案:
Currently, the XmlRpc++ libraryby Chris Morley is the only public domain/LPGL XmlRpc implementation for C++ on Windows.
目前,Chris Morley 的 XmlRpc ++ 库是 Windows 上 C++ 的唯一公共域/LPGL XmlRpc 实现。
There are a couple of C++ implementations for Linux, either of which could be presumably easily ported to Windows, but the fact seems to be that no-one has yet done so and made it publicly available. Also, as eczamy says, "The XML-RPC specification is somewhat simple and it would not be difficult to implement your own XML-RPC client."
有几个适用于 Linux 的 C++ 实现,其中任何一个都可以很容易地移植到 Windows,但事实似乎是没有人这样做并公开可用。此外,正如 eczamy 所说,“XML-RPC 规范有些简单,实现您自己的 XML-RPC 客户端并不困难。”
I'm using Chris Morley's library successfully, despite having had to find and fix quite a number of bugs. The Help Forumfor this project seems to be somewhat active, but no-one has fixed these bugs and done a new release. I have been in correspondence with Chris Morley and he has vague hopes to do a new release, and he has contributed to this stackOverflow question (see below/above) and he claims to have fixed most of the bugs, but so far he has not made a release that fixes the many bugs. The last release was in 2003.
我成功地使用了 Chris Morley 的库,尽管必须找到并修复相当多的错误。这个项目的帮助论坛似乎有些活跃,但没有人修复这些错误并发布新版本。我一直在与 Chris Morley 通信,他模糊地希望做一个新版本,他对这个 stackOverflow 问题做出了贡献(见下文/上文),他声称已经修复了大部分错误,但到目前为止他还没有发布了一个修复了许多错误的版本。最后一次发布是在 2003 年。
It is disappointing to me that a supposed widely supported (and simple!) protocol has such poor support on Windows + C++. Please can someone reading this page pick up the baton and e.g. take over XmlRpc++ or properly port one of the Linux implementations.
令我失望的是,一个假设得到广泛支持(而且很简单!)的协议对 Windows + C++ 的支持如此之差。请阅读本页的人拿起指挥棒,例如接管 XmlRpc++ 或正确移植 Linux 实现之一。
回答by Chris Morley
Just wanted to note a couple of items:
只是想注意几个项目:
The source in the cvs repository for XmlRpc++ has support for OpenSSL (although I have not tried it, it was contributed by another developer).
Most of the reported bugs are fixed in cvs; I don't have access to a linux machine at the moment, so I haven't made an official release.
XmlRpc++is not public domain. It is copyrighted and licensed (LGPL).
XmlRpc++ cvs 库中的源代码支持 OpenSSL(虽然我没有尝试过,但它是由另一位开发人员提供的)。
大多数报告的错误已在 cvs 中修复;我目前无法访问 linux 机器,所以我还没有正式发布。
XmlRpc++不是公共领域。它受版权保护和许可 (LGPL)。
Thanks, Chris Morley
谢谢,克里斯莫利
回答by eczarny
There are dozens of implementations of the XML-RPC implementations, some in C++, but most in other languages. For example, besides XmlRpc++ there is also XML-RPC for C and C++. Here is a HOWTOon how the XML-RPC for C and C++ library can be used.
XML-RPC实现有数十种实现,一些使用 C++,但大多数使用其他语言。例如,除了 XmlRpc++ 之外,还有用于 C 和 C++ 的 XML-RPC。这是关于如何使用 XML-RPC for C 和 C++ 库的HOWTO。
The XML-RPC specification is somewhat simple and it would not be difficult to implement your own XML-RPC client. Not to mention, it would also be possible to take an existing XML-RPC implementation in C and bring into your C++ project.
XML-RPC 规范有些简单,实现您自己的 XML-RPC 客户端并不困难。更不用说,还可以在 C 中采用现有的 XML-RPC 实现并将其引入您的 C++ 项目。
The XML-RPC home pagealso provides a lot of useful information.
XML-RPC主页还提供了很多有用的信息。
回答by highvelcty
I was able to get Tim's version of xml rpc working with https and with basic username / password authentication.
我能够让 Tim 的 xml rpc 版本与 https 和基本的用户名/密码身份验证一起使用。
For the authentication:
对于身份验证:
1) the username and password need to be passed to the InternetConnect(...) function
1)用户名和密码需要传递给InternetConnect(...)函数
2) an http request header of "Authorization: Basic base64encoded(user:pass)" needs to be added prior to sending the HttpSendRequest(...) command.
2)发送HttpSendRequest(...)命令前需要添加“Authorization: Basic base64encoded(user:pass)”的http请求头。