我有一个在unix 环境 上运行的C 应用程序。我需要连接到 RESTful 服务,到目前为止,我所有的谷歌搜索都显示了如何连接到 soap 服务。为了连接到 soap 服务,我手动创建 xml 并将其发送出去。人们告诉我,我需要将 REST 服务包装到 soap 服务中,并调用 soap 服务以获取 REST 服务。
有没有一种方法可以只导入一个 dll/模块并直接连接到 REST 服务,而无需编写 SOAP 包装器?
最佳答案
People have told me I need to wrap the REST service into a soap service and call the soap service to get to the REST services.
别再听那些人的了。他们似乎不知道自己在说什么。
Is there a way I can just import a dll/module and connect to the REST service directly without having to write the SOAP wrapper?
阅读 REST。从 How I Explained REST to My Wife 开始.主要思想是使用 GET 和 POST 等 HTTP 命令/动词直接与另一台机器交互,而不必像 SOAP 那样将事情包装在复杂的信封中。访问 RESTful 服务器就像发出 HTTP 请求一样简单。关键是知道该说什么——您如何为代表您想要的数据的系统构建一个 URL?您需要查看您计划为此访问的特定服务。
如果您在使用 C 中的 HTTP 方面需要帮助,请查看 libcurl .
关于使用 C 连接到 REST 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12161016/