暴露 C++程序即 Web 服务
如何将 C++ 程序公开为 Web 服务? 或者从 Java 调用 C++ 并将生成的 Java 作为 Web 服务公开是一个更好的主意。
无论如何,C++ 程序不应进行任何更改。
How to expose a C++ program as a Web Service?
Or is it a better idea to invoke C++ from Java and expose the resultant Java as a Web Service.
In any case, the C++ program should not undergo any changes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Java WebService 端点中使用 C++ 程序并公开 java webservice
使用 JNI 来使用 C++ 程序
Consume C++ program in Java WebService end point and expose java webservice
Use JNI to consume C++ program
有趣的是,Web 服务基于 http 协议工作,这意味着如果没有 http 服务器,您就无法“托管”用 C++ 编写的 Web 服务。由于每个 Web 服务器都有自己的编写“钩子”或扩展的机制,因此下一个明显的问题是您要选择哪个 Web 服务器。
假设您想要 Windows 上的 IIS。可以使用 ISAPI 扩展;因此您需要知道如何编写一个符合 Web 服务标准的程序。或者,最好学习如何使用 Visual Studio 在 C++ 中执行此操作,其中会有很多 可帮助您入门的内置内容。
简而言之,在 C++ 中不存在公开 Web 服务的“标准”方法,您必须特定于“平台”。带有 IIS 的 Windows 有一种方法可以做到这一点。 Apache Axis C++ 还有另一个。
Interestingly, webservices work on http protocol, which means that you can't "host" a webservice written in C++ without having an http server. Since each web server will have it's own mechanism of writing "hooks" or extensions, the next obvious question is which web server would you like to chose.
Let's say you want IIS on Windows. It's possible to use ISAPI extensions; so you need to know how to write one, which complies with web services standards. Or, alternatively, it's better to learn how to do it in C++ with Visual Studio, which will have lots of built-in stuff to help you get started.
In short, there is no "standard" way of exposing a web service in C++ and you have to be "platform" specific. Windows with IIS has one way of doing it. Apache Axis C++ has another.
您可以尝试 c-sevice-interface https://github.com/Taymindis/c-service-界面。
它创建一个 C/C++ 程序作为服务端口并监听 NGINX fcgi。
这是一个小型桥接引擎,可以处理高负载的请求,任何段错误都不会破坏引擎,它会捕获并释放线程,它构建在 NGINX、FCGI 之上。在到达您的界面之前,您可以通过 NGINX 设置代理、负载平衡、身份验证。
下面显示的链接是一个 wiki,指导您如何从头开始。
https://github.com/ Taymindis/backcurl/wiki/如何构建 BackCurl-for-cpp-Android-development
You can try c-sevice-interface https://github.com/Taymindis/c-service-interface.
It create a C/C++ program as a service port and listening to NGINX fcgi.
This is a small bridge engine which can handle high load of request, any segfault will not break the engine, it will catch and free the thread, it is built on top NGINX, FCGI. You can setup the proxy, load balance, authentication via NGINX before reach to your interface.
The link shown as below is a wiki to Guide you how to startup from scratch.
https://github.com/Taymindis/backcurl/wiki/How-to-build-BackCurl-for-cpp-Android-development