简体   繁体   English

C / C ++代码与服务器(tomcat)上的远程Web服务通信

[英]C / C++ code communicates with a remote web service on server (tomcat)

I have C++ HTTP code on the client side which will communicate with a remote web service on the server side. 我在客户端具有C ++ HTTP代码,它将与服务器端的远程Web服务进行通信。
The server is Tomcat Apache server which is configured on port 8080. The webservice which I have to access through my C++ http code is at: 该服务器是在端口8080上配置的Tomcat Apache服务器。我必须通过C ++ http代码访问的Web服务位于:

http://somehostname:8080/some_path/some_api 

Is this possible? 这可能吗?

1st confusion: I know that HTTP POST requests are sent on port 80 and here I have port 8080. 第一个困惑:我知道HTTP POST请求是在端口80上发送的,这里我有8080端口。

2nd confusion: The server is Tomcat Apache and the server code(webservice) is in java . 第二个困惑:服务器是Tomcat Apache,服务器代码(webservice)在java中 This means that I have to access that java code through my C++ HTTP POST method. 这意味着我必须通过我的C ++ HTTP POST方法访问该Java代码。 Is it possible to communicate C++ HTTP POST method to JAVA? 是否可以将C ++ HTTP POST方法传递给JAVA?

what i know that HTTP request(POST) is sent on port 80 and here i have port 8080 我知道HTTP请求(POST)是在端口80上发送的,这里我有8080端口

An application can use any available/free port. 应用程序可以使用任何可用/可用端口。 By convention certain ports are used by specific applications. 按照惯例,某些端口由特定应用程序使用。 Eg usually HTTP servers run on port 80 but they can also run on 8080 or any other port. 例如,HTTP服务器通常在端口80上运行,但它们也可以在8080或任何其他端口上运行。

the server is tomcat server and the server code(webservice) is in java that means the i have to access that java code through my c++ HTTP POST method is it possible to communicate c++ HTTP POST method to JAVA ?? 服务器是tomcat服务器,服务器代码(webservice)是用Java编写的,这意味着我必须通过我的c ++ HTTP POST方法访问该Java代码,才能将c ++ HTTP POST方法传递给JAVA?

Yes it is possible. 对的,这是可能的。
You are essentially sending an HTTP message that the receiving side ie the Java application can "understand" it since it will be formed according to the HTTP standard (an HTTP message has a specific format). 本质上,您正在发送一条HTTP消息,接收方(即Java应用程序)可以“理解”它,因为它将根据HTTP标准形成(HTTP消息具有特定格式)。
All in all an HTTP message is plain text. 总而言之,HTTP消息是纯文本。

You should note though that in general there are many pitfalls when you try to communicate a C++ application with a Java application as there are subtle differences eg Java's lack of unsigned primitives compared to C++ etc 您应该注意,尽管通常在尝试与Java应用程序通信C ++应用程序时会遇到很多陷阱,因为它们之间存在细微的差异,例如与C ++相比Java缺少无符号原语等

Yes it's possible. 是的,有可能。

  1. Just configure the c++ client with a url endpoint as per your example. 只需按照您的示例为c ++客户端配置一个url端点即可。
  2. Yes a c++ client can communicate with a Java server using HTTP. 是的,c ++客户端可以使用HTTP与Java服务器通信。 HTTP POST is not java or c++ specific. HTTP POST不是特定于Java或c ++的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM