CN113821352A - Remote service calling method and device - Google Patents

Remote service calling method and device Download PDF

Info

Publication number
CN113821352A
CN113821352A CN202110144183.4A CN202110144183A CN113821352A CN 113821352 A CN113821352 A CN 113821352A CN 202110144183 A CN202110144183 A CN 202110144183A CN 113821352 A CN113821352 A CN 113821352A
Authority
CN
China
Prior art keywords
calling
service
request
proxy server
framework
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110144183.4A
Other languages
Chinese (zh)
Inventor
李明昊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110144183.4A priority Critical patent/CN113821352A/en
Publication of CN113821352A publication Critical patent/CN113821352A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • G06F9/548Object oriented; Remote method invocation [RMI]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • G06F13/4286Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus using a handshaking protocol, e.g. RS232C link

Abstract

The invention discloses a method and a device for calling remote services, and relates to the technical field of computers. One embodiment of the method comprises: receiving a first call request for the remote service, and responding to the first call request to acquire a corresponding framework call code; based on the first calling request, generating a second calling request for the proxy server by using the frame calling code, so that the proxy server requests the service frame system through a TCP protocol according to the second calling request and obtains a remote service calling result; and receiving a remote service calling result returned by the proxy server to realize the calling of the remote service. The implementation method can configure corresponding framework calling codes for the client, further utilize the framework calling codes to generate a calling request for the remote service through a TCP protocol in a cross-language mode in a calling process, realize cross-language cross-platform communication decoupling of the server and the client, enable a caller to realize free language development, and improve the whole calling speed.

Description

Remote service calling method and device
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for calling remote services.
Background
With the development and expansion of the internet scale, Service functions are continuously subdivided, and users often call services in a Service Framework system (such as Jingdong Service Framework system in kyoto) to meet functional requirements. In remote service invocation, when the service framework system does not support direct invocation, a gateway is required to be requested through HTTP to realize remote invocation.
In the process of implementing the invention, the prior art at least has the following problems:
some service framework systems only support remote calling between backgrounds of fixed development languages, and cannot meet the requirements of cross-platform and cross-language remote calling, so that when a PC (personal computer) end or a mobile end or background calling services of other development languages are used, the remote services need to be called through an HTTP (hyper text transport protocol) request gateway; compared with a remote call self-defined TCP protocol, the HTTP protocol has a larger message volume, so that the data transmission performance in unit time can be influenced, and further, when the data volume is larger, the speed of providing remote service by the conventional service framework system is often influenced.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for invoking a remote service, which can configure a corresponding framework invocation code for a client, and further generate an invocation request for the remote service through a TCP protocol in a cross-language manner in an invocation process using the framework invocation code, so as to implement cross-language and cross-platform communication decoupling between a server and the client, and enable a caller to implement free language development; and the request can be generated only through the TCP protocol in the calling process, so that the whole calling speed is improved, and the user experience is improved.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method for invoking a remote service, including:
receiving a first call request for a remote service, and responding to the first call request to acquire a corresponding framework call code;
based on the first calling request, generating a second calling request for the proxy server by using the framework calling code, so that the proxy server requests a service framework system through a TCP protocol according to the second calling request and obtains a remote service calling result;
and receiving a remote service calling result returned by the proxy server to realize the calling of the remote service.
Optionally, obtaining the corresponding framework invocation code in response to the first invocation request includes:
analyzing the first calling request, and determining a service identifier indicated by the first calling request;
acquiring a corresponding frame calling code from a preset file storage system according to the service identifier; or acquiring a service contract file from a preset file storage system according to the service identifier, and generating a frame calling code corresponding to the service identifier based on the service contract file.
Optionally, the method for invoking a remote service further includes:
the language type of the framework calling code is consistent with the language type of the first calling request.
Optionally, after obtaining the corresponding framework invocation code, the method further includes:
and implanting the framework calling code into client code.
Optionally, the parsing the first invocation request further includes: analyzing the first calling request to determine the access information indicated by the first calling request;
and generating a second call request to the proxy server by using the framework call code based on the first call request, wherein the second call request comprises:
performing serialized expression on the reference information by using the frame calling code; and generating a second calling request to the proxy server through a TCP (transmission control protocol) protocol based on the serialized expression result.
Optionally, making the proxy server request the service framework system through a TCP protocol according to the second invocation request and obtain a remote service invocation result includes:
performing deserialization expression on the serialization expression result in the second call request by using the proxy server;
generating a third calling request for the remote service in the service framework system through a TCP (transmission control protocol) protocol by utilizing the proxy server based on the result of the deserialization expression;
and receiving the remote service calling result returned by the service framework system in response to the third calling request by utilizing the proxy server.
Optionally, before the making the proxy server request the service framework system through the TCP protocol according to the second invocation request and obtain the remote service invocation result, the method further includes:
configuring a framework service code for the proxy server in advance based on the service contract file;
generating SPI interface data of a service producer called by a service consumer in the service framework system through Javaassist by utilizing the framework service code, and transmitting the SPI interface data into a development toolkit of the service framework system; and the number of the first and second groups,
generating, with the proxy server, a third invocation request for the remote service in the service framework system via a TCP protocol based on a result of the deserialization expression, including:
and adapting the result of the deserialization expression with the SPI interface data by using the proxy server to determine the service interface data of the remote service, and further generating the third calling request through a TCP (transmission control protocol) protocol based on the service interface data.
According to still another aspect of the embodiments of the present invention, there is provided a remote service invoking apparatus, including:
the system comprises a receiving module, a frame calling module and a frame calling module, wherein the receiving module is used for receiving a first calling request for remote service and responding to the first calling request to acquire a corresponding frame calling code;
the calling module is used for generating a second calling request for the proxy server by utilizing the frame calling code based on the first calling request so that the proxy server requests a service frame system through a TCP protocol according to the second calling request and obtains a remote service calling result;
and the execution module is used for receiving a remote service calling result returned by the proxy server so as to realize the calling of the remote service.
Optionally, the receiving module, in response to the first call request, acquires a corresponding framework call code, including:
analyzing the first calling request, and determining a service identifier indicated by the first calling request;
acquiring a corresponding frame calling code from a preset file storage system according to the service identifier; or acquiring a service contract file from a preset file storage system according to the service identifier, and generating a frame calling code corresponding to the service identifier based on the service contract file.
Optionally, the language type of the framework call code is consistent with the language type of the first call request.
Optionally, after obtaining the corresponding framework invocation code, the receiving module further includes:
and implanting the framework calling code into client code.
Optionally, the parsing, by the receiving module, the first call request further includes: analyzing the first calling request to determine the access information indicated by the first calling request;
and the calling module generates a second calling request for the proxy server by utilizing the framework calling code based on the first calling request, and the method comprises the following steps:
performing serialized expression on the reference information by using the frame calling code; and generating a second calling request to the proxy server through a TCP (transmission control protocol) protocol based on the serialized expression result.
Optionally, the invoking module enables the proxy server to request the service framework system through a TCP protocol according to the second invoking request and obtain a remote service invoking result, including:
performing deserialization expression on the serialization expression result in the second call request by using the proxy server;
generating a third calling request for the remote service in the service framework system through a TCP (transmission control protocol) protocol by utilizing the proxy server based on the result of the deserialization expression;
and receiving the remote service calling result returned by the service framework system in response to the third calling request by utilizing the proxy server.
Optionally, before the invoking module makes the proxy server request the service framework system through the TCP protocol according to the second invocation request and obtain the remote service invocation result, the method further includes:
configuring a framework service code for the proxy server in advance based on the service contract file;
generating SPI interface data of a service producer called by a service consumer in the service framework system through Javaassist by utilizing the framework service code, and transmitting the SPI interface data into a development toolkit of the service framework system; and the number of the first and second groups,
generating, with the proxy server, a third invocation request for the remote service in the service framework system via a TCP protocol based on a result of the deserialization expression, including:
and adapting the result of the deserialization expression with the SPI interface data by using the proxy server to determine the service interface data of the remote service, and further generating the third calling request through a TCP (transmission control protocol) protocol based on the service interface data.
According to another aspect of the embodiments of the present invention, there is provided an electronic device for invoking a remote service, including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the calling method of the remote service provided by the present invention.
According to still another aspect of an embodiment of the present invention, there is provided a computer-readable medium on which a computer program is stored, the program implementing a method for calling a remote service provided by the present invention when executed by a processor.
One embodiment of the above invention has the following advantages or benefits: the technical means that the client and the server are configured with corresponding function codes, and the function codes are used for generating the call request through the TCP protocol in a cross-language mode in the call process is adopted, so that the technical problem that in the prior art, the speed is low due to the fact that the cross-platform and cross-language remote call requirement cannot be met, and the remote service call needs to be carried out through the HTTP request gateway is solved, the cross-language and cross-platform communication decoupling of the server and the client is achieved, a caller can freely develop the language, the request can be generated only through the TCP protocol in the call process, and the technical effects that the overall call speed is improved and the user experience is improved are achieved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a method for calling a remote service according to a first embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for invoking a remote service according to a second embodiment of the present invention;
fig. 3 is a schematic configuration diagram of a proxy server cluster in a method for calling a remote service according to a third embodiment of the present invention;
FIG. 4 is a schematic diagram of communication between a client and a proxy server in a method for invoking a remote service according to a fourth embodiment of the present invention;
FIG. 5 is a block diagram of a method for invoking a remote service according to a fifth embodiment of the present invention;
FIG. 6 is a block diagram of a method for invoking a remote service according to a sixth embodiment of the present invention;
fig. 7 is a schematic diagram of a visualization window for configuring a proxy server in a method for invoking a remote service according to a seventh embodiment of the present invention;
fig. 8 is a schematic view of a visualization window for monitoring an interface through a proxy server in a method for invoking a remote service according to an eighth embodiment of the present invention;
fig. 9 is a schematic view of a visualization window for generating function codes according to a service contract file in a method for calling a remote service according to a ninth embodiment of the present invention;
fig. 10 is a schematic diagram of main blocks of a calling apparatus of a remote service according to a tenth embodiment of the present invention;
FIG. 11 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 12 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of a method for calling a remote service according to a first embodiment of the present invention, as shown in fig. 1, including:
step S101, receiving a first call request for remote service, and responding to the first call request to obtain a corresponding frame call code;
step S102, based on the first calling request, generating a second calling request for the proxy server by using the frame calling code, so that the proxy server requests a service frame system through a TCP protocol according to the second calling request and obtains a remote service calling result;
and step S103, receiving a remote service calling result returned by the proxy server to realize the calling of the remote service.
The first call request is initiated by a caller user and can contain service information, such as a service name to be called, access information and the like; the calling party user can be a front-end developer or a back-end developer; in some practical applications, before the client receives the first call request, an agent control class may be set for an interceptor for preliminary interception, so as to prevent the client from receiving an interference request or an error request; the client may be a scenario in which a front end initiates a call, or a scenario in which a back end initiates a call, and the client may include: background client, mobile client, PC client, etc.; the Service Framework system may be an open-source micro-Service Framework, an intra-enterprise Service Framework (e.g., Jingdong Service Framework, JSF kyoto Service Framework), and the like.
By the method, the corresponding framework calling code can be configured for the client, and then the framework calling code is utilized to generate a calling request for the remote service through a TCP protocol in a cross-language mode in a calling process, so that cross-language and cross-platform communication decoupling of the server and the client is realized, and a caller can freely develop languages; and the request can be generated only through the TCP protocol in the calling process, so that the whole calling speed is improved, and the user experience is improved.
Fig. 2 is a flowchart illustrating a method for invoking a remote service according to a second embodiment of the present invention, as shown in fig. 2, including:
step S201, a developer inputs service information (the service information can be in the form of the first calling request and specifically can comprise a service name to be called, access information and the like), and the service information is received by a proxy tool control class;
step S202, after receiving the service information, the agent tool control class sends the service information to the client;
step S203, the client generates a second calling request according to the received service information (the first calling request) and is used for requesting the proxy server;
step S204, after receiving the second calling request, the proxy server requests a service framework system for remote service calling;
step S205, the service framework system returns a remote service calling result to the proxy server;
step S206, the proxy server returns the received remote service calling result to the client;
step S207, the client executes the called remote service based on the remote service calling result and returns the execution result to the agent tool control class;
step S208, the agent tool control class returns/displays the execution result of the remote call success or failure to the developer.
In some embodiments, obtaining the corresponding framework invocation code in response to the first invocation request includes:
analyzing the first calling request, and determining a service identifier indicated by the first calling request;
acquiring a corresponding frame calling code from a preset file storage system according to the service identifier; or acquiring a service contract file from a preset file storage system according to the service identifier, and generating a frame calling code corresponding to the service identifier based on the service contract file.
Further, in some embodiments, the method for invoking a remote service further comprises: the language type of the framework calling code is consistent with the language type of the first calling request.
In some embodiments, after obtaining the corresponding framework invocation code, the method further includes:
and implanting the framework calling code into client code.
The service identifier can be used for uniquely identifying the remote service to be called; the corresponding relation between the service name and the service identifier can be stored in advance, and the service identifier can be determined according to the service name in the first calling request. The preset file storage system may be a preset database for storing the framework calling code or the service contract file.
The frame calling code in the file storage system can be a code which is generated in advance according to the service contract file and is suitable for each remote service and each language, and then the corresponding frame calling code can be determined according to the language type of the first calling request and the service identifier; or, after receiving the first call request, generating a corresponding frame call code according to the service contract file in the file storage system; can be flexibly set according to the actual situation;
after the corresponding framework calling code is obtained, the code can be implanted into the original client code, so that the corresponding function of the framework calling code is applied; such as: when a web front end is used for calling the applet in the service framework system, the framework calling code of the JavaScript language can be generated by using the service contract file and is put into the JS code at the front end, so that when the front end page is operated, a method corresponding to the newly-implanted framework calling code can be directly executed in the JS file to call the proxy server, and a method for calling the remote service through the HTTP request gateway is not executed, so that the cross-language calling service requirement is met.
In some practical applications, the languages of the framework call code generated by the application to the android and IOS clients may be JAVA and Objective C, respectively.
In some embodiments, said parsing said first invocation request further comprises: analyzing the first calling request to determine the access information indicated by the first calling request;
and generating a second call request to the proxy server by using the framework call code based on the first call request, wherein the second call request comprises: performing serialized expression on the reference information by using the frame calling code; and generating a second calling request to the proxy server through a TCP (transmission control protocol) protocol based on the serialized expression result.
In some embodiments, the causing the proxy server to request and obtain the remote service invocation result from the service framework system according to the second invocation request through a TCP protocol includes: performing deserialization expression on the serialization expression result in the second call request by using the proxy server; generating a third calling request for the remote service in the service framework system through a TCP (transmission control protocol) protocol by utilizing the proxy server based on the result of the deserialization expression; and receiving the remote service calling result returned by the service framework system in response to the third calling request by utilizing the proxy server.
In some embodiments, before the making the proxy server request the service framework system through the TCP protocol according to the second invocation request and obtain the remote service invocation result, the method further includes: configuring a framework service code for the proxy server in advance based on the service contract file; generating SPI interface data of a service producer called by a service consumer in the service framework system through Javaassist by utilizing the framework service code, and transmitting the SPI interface data into a development toolkit of the service framework system; and the number of the first and second groups,
generating, with the proxy server, a third invocation request for the remote service in the service framework system via a TCP protocol based on a result of the deserialization expression, including:
and adapting the result of the deserialization expression with the SPI interface data by using the proxy server to determine the service interface data of the remote service, and further generating the third calling request through a TCP (transmission control protocol) protocol based on the service interface data.
The framework service code can be configured in advance, or can be generated by acquiring a service contract file from a preset file storage system after the proxy server receives the second call request;
the third call request is a call request of a service consumer to a service producer in a service framework system (such as JSF Jingdong service framework).
Fig. 3 is a schematic configuration diagram of a proxy server cluster in a remote service invoking method according to a third embodiment of the present invention, as shown in fig. 3:
three host clusters can be configured, one cluster is used for deploying registry service, and developers can manually register interfaces; and when the proxy server node receives a first call request sent by a client, the proxy server node can deserialize interface information (access parameter information) to request to acquire a service contract file, simultaneously generates an SPI (serial peripheral interface) class corresponding to the service through Javaass, and then adapts the deserialization result of the interface information with the access parameter of the SPI class to call the SDK in the service framework system to generate the third call request.
Fig. 4 is a schematic diagram of communication between a client and a proxy server in a method for invoking a remote service according to a fourth embodiment of the present invention, as shown in fig. 4:
in the application, the client communication of the cross-language is realized mainly based on a service interface of a service framework system and the language of the client, framework calling codes of corresponding languages are generated for the client, and framework service codes of corresponding languages are configured for the proxy server;
the framework call code of the client may provide two functions: communication and coding and decoding; the communication function can be realized by using Netty, the coding and decoding function can be used for serialization of data among different languages, and the rest part can be a service logic code of a client;
the proxy server generates a framework service code according to the interface contract file, further generates SPI interface data of a service consumer calling service producer in the service framework system by using the framework service code through Javaassist, transmits the SPI interface data into a development kit of the service framework system, transmits client requests into the development kit of the service framework system in a deserialization mode through coding and decoding, and requests the service producer in the service framework system through the development kit to obtain a corresponding remote service calling result.
Fig. 5 is a schematic diagram of a framework of a method for invoking a remote service according to a fifth embodiment of the present invention, as shown in fig. 5, including:
the proxy server can be registered in the registration center;
when the background client/the mobile client/the PC client receives the calling request, generating a second calling request for the proxy server by utilizing the frame calling code;
after receiving the second call request, the proxy server obtains the service contract File from JFS (slingding File sys em), so as to generate a framework service code, deserializes information in the second call request by using the framework service code, and further generates a third call request for calling a remote service in a service framework system (JSF), thereby realizing remote call.
Fig. 6 is a schematic diagram of a framework of a method for invoking a remote service according to a sixth embodiment of the present invention, as shown in fig. 6, including:
after the client receives the first calling request, the name of the service to be called is 'service 2' and a plurality of access parameter information 'IP + ports' can be obtained through analysis;
and addressing the registry through the access parameter information 'IP + port', finding a corresponding proxy server, and requesting and obtaining a calling result of the remote service 'service 2' from a service framework system (JSF) through the proxy server.
Fig. 7 is a schematic diagram of a visualization window for configuring a proxy server in a method for invoking a remote service according to a seventh embodiment of the present invention, as shown in fig. 7:
operation and maintenance personnel of the proxy server can newly build a configuration file in a project, can select a 'generating' function through a right key, input an ip address and a port number through selecting a protocol TCP, generate a configuration file code and then select deployment through the right key, and complete deployment of a registry and proxy server nodes.
Fig. 8 is a schematic diagram of a visualization window for monitoring an interface through a proxy server in an invoking method of a remote service according to an eighth embodiment of the present invention, as shown in fig. 8:
the deployed registry, the server nodes and the deployment state of consumer services (such as JSF) in the service framework system can be checked through the proxy server monitoring interface, and the server nodes can be started or suspended by a right key.
Fig. 9 is a schematic diagram of a visualization window for generating function codes according to a service contract file in a method for calling a remote service according to a ninth embodiment of the present invention, as shown in fig. 9:
the service contract file can be defined according to the service frame system interface information, then the language, the ip address and the port number of the proxy server are selected according to the service contract file, frame calling codes of clients with different languages are generated locally, after the generation is finished, the service contract file can be sent to JFS for storage, and finally the frame calling codes can be placed into front and back end projects of corresponding language environments to be called.
Fig. 10 is a schematic diagram of main blocks of a remote service invocation apparatus according to a tenth embodiment of the present invention, and as shown in fig. 10, the remote service invocation apparatus 1000 includes:
a receiving module 1001, configured to receive a first call request for a remote service, and obtain a corresponding framework call code in response to the first call request;
the invoking module 1002 is configured to generate a second invoking request for the proxy server by using the framework invoking code based on the first invoking request, so that the proxy server requests the service framework system through a TCP protocol according to the second invoking request and obtains a remote service invoking result;
the executing module 1003 is configured to receive a remote service invocation result returned by the proxy server, so as to implement invocation of the remote service.
The first calling request is initiated by a calling party and can contain service information, such as a service name to be called, entry parameter information and the like; the calling party can be a front-end developer or a back-end developer; in some practical applications, before the client receives the first call request, an agent control class may be set for an interceptor for preliminary interception, so as to prevent the client from receiving an interference request or an error request; the client may be a scenario in which a front end initiates a call, or a scenario in which a back end initiates a call, and the client may include: background client, mobile client, PC client, etc.
By the method, the corresponding framework calling code can be configured for the client, and then the framework calling code is utilized to generate a calling request for the remote service through a TCP protocol in a cross-language mode in a calling process, so that cross-language and cross-platform communication decoupling of the server and the client is realized, and a caller can freely develop languages; and the request can be generated only through the TCP protocol in the calling process, so that the whole calling speed is improved, and the user experience is improved.
In some embodiments, the receiving module, in response to the first invocation request, obtains the corresponding framework invocation code, including:
analyzing the first calling request, and determining a service identifier indicated by the first calling request;
acquiring a corresponding frame calling code from a preset file storage system according to the service identifier; or acquiring a service contract file from a preset file storage system according to the service identifier, and generating a frame calling code corresponding to the service identifier based on the service contract file.
Further, in some embodiments, the language type of the framework invocation code is consistent with the language type of the first invocation request.
In some embodiments, after obtaining the corresponding framework invocation code, the receiving module further includes:
and implanting the framework calling code into client code.
The service identifier can be used for uniquely identifying the remote service to be called; the corresponding relation between the service name and the service identifier can be stored in advance, and the service identifier can be determined according to the service name in the first calling request. The preset file storage system may be a preset database for storing the framework calling code or the service contract file.
The frame calling code in the file storage system can be a code which is generated in advance according to the service contract file and is suitable for each remote service and each language, and then the corresponding frame calling code can be determined according to the language type of the first calling request and the service identifier; or, after receiving the first call request, generating a corresponding frame call code according to the service contract file in the file storage system; can be flexibly set according to the actual situation;
after the corresponding framework calling code is obtained, the code can be implanted into the original client code, so that the corresponding function of the framework calling code is applied; such as: when a web front end is used for calling the applet in the service framework system, the framework calling code of the JavaScript language can be generated by using the service contract file and is put into the JS code at the front end, so that when the front end page is operated, a method corresponding to the newly-implanted framework calling code can be directly executed in the JS file to call the proxy server, and a method for calling the remote service through the HTTP request gateway is not executed, so that the cross-language calling service requirement is met.
In some practical applications, the languages of the framework call code generated by the application to the android and IOS clients may be JAVA and Objective C, respectively.
In some embodiments, the receiving module parses the first invocation request, further comprising: analyzing the first calling request to determine the access information indicated by the first calling request;
and the calling module generates a second calling request for the proxy server by utilizing the framework calling code based on the first calling request, and the method comprises the following steps:
performing serialized expression on the reference information by using the frame calling code; and generating a second calling request to the proxy server through a TCP (transmission control protocol) protocol based on the serialized expression result.
In some embodiments, the invoking module causes the proxy server to request and obtain the remote service invoking result from the service framework system according to the second invoking request through a TCP protocol, including:
performing deserialization expression on the serialization expression result in the second call request by using the proxy server;
generating a third calling request for the remote service in the service framework system through a TCP (transmission control protocol) protocol by utilizing the proxy server based on the result of the deserialization expression;
and receiving the remote service calling result returned by the service framework system in response to the third calling request by utilizing the proxy server.
In some embodiments, before the invoking module causes the proxy server to request the service framework system through the TCP protocol according to the second invocation request and obtain the remote service invocation result, the invoking module further includes:
configuring a framework service code for the proxy server in advance based on the service contract file;
generating SPI interface data of a service producer called by a service consumer in the service framework system through Javaassist by utilizing the framework service code, and transmitting the SPI interface data into a development toolkit of the service framework system; and the number of the first and second groups,
generating, with the proxy server, a third invocation request for the remote service in the service framework system via a TCP protocol based on a result of the deserialization expression, including:
and adapting the result of the deserialization expression with the SPI interface data by using the proxy server to determine the service interface data of the remote service, and further generating the third calling request through a TCP (transmission control protocol) protocol based on the service interface data.
The framework service code can be configured in advance, or can be generated by acquiring a service contract file from a preset file storage system after the proxy server receives the second call request;
the third call request is a call request of a service consumer to a service producer in a service framework system (such as JSF Jingdong service framework).
Fig. 11 shows an exemplary system architecture 1100 of a remote service invocation method or a remote service invocation means to which embodiments of the present invention may be applied.
As shown in fig. 11, the system architecture 1100 may include terminal devices 1101, 1102, 1103, a network 1104, and a server 1105. The network 1104 is a medium to provide communication links between the terminal devices 1101, 1102, 1103 and the server 1105. Network 1104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 1101, 1102, 1103 to interact with a server 1105 over a network 1104 to receive or send messages or the like. Various applications having a remote call demand may be installed on the terminal devices 1101, 1102, 1103.
The terminal devices 1101, 1102, 1103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 1105 may be a server that provides various services, such as a management server that provides support for a user to remotely invoke a demand with the terminal devices 1101, 1102, 1103. The management server may process the received call request and feed back a processing result (e.g., a call result of the service) to the terminal device.
It should be noted that the method for calling the remote service provided by the embodiment of the present invention is generally executed by the server 1105, and accordingly, the means for calling the remote service is generally disposed in the server 1105.
It should be understood that the number of terminal devices, networks, and servers in fig. 11 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 12, shown is a block diagram of a computer system 1200 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 12 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 12, the computer system 1200 includes a Central Processing Unit (CPU)1201, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)1202 or a program loaded from a storage section 1208 into a Random Access Memory (RAM) 1203. In the RAM 1203, various programs and data necessary for the operation of the system 1200 are also stored. The CPU 1201, ROM 1202, and RAM 1203 are connected to each other by a bus 1204. An input/output (I/O) interface 1205 is also connected to bus 1204.
The following components are connected to the I/O interface 1205: an input section 1206 including a keyboard, a mouse, and the like; an output portion 1207 including a display device such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 1208 including a hard disk and the like; and a communication section 1209 including a network interface card such as a LAN card, a modem, or the like. The communication section 1209 performs communication processing via a network such as the internet. A driver 1210 is also connected to the I/O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is mounted on the drive 1210 as necessary, so that a computer program read out therefrom is mounted into the storage section 1208 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 1209, and/or installed from the removable medium 1211. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 1201.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a receiving module, a calling module and an executing module. Wherein the names of the modules do not in some cases constitute a limitation of the module itself.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: step S101, receiving a first call request for remote service, and responding to the first call request to obtain a corresponding frame call code; step S102, based on the first calling request, generating a second calling request for the proxy server by using the frame calling code, so that the proxy server requests a service frame system through a TCP protocol according to the second calling request and obtains a remote service calling result; and step S103, receiving a remote service calling result returned by the proxy server to realize the calling of the remote service.
According to the technical scheme of the embodiment of the invention, the technical means that the corresponding function codes are configured for the client and the server, and the function codes are utilized to generate the call request through the TCP protocol in a cross-language mode in the call process is adopted, so that the technical problem that the speed is low because the remote call requirement of the cross-platform and cross-language mode cannot be met in the prior art and the remote service call needs to be carried out through an HTTP request gateway is solved, the cross-language and cross-platform communication decoupling of the server and the client is further realized, the caller is free in language development, the request can be generated only through the TCP protocol in the call process, and the technical effects of improving the whole call speed and improving the user experience are achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for invoking a remote service, comprising:
receiving a first call request for a remote service, and responding to the first call request to acquire a corresponding framework call code;
based on the first calling request, generating a second calling request for the proxy server by using the framework calling code, so that the proxy server requests a service framework system through a T CP protocol according to the second calling request and obtains a remote service calling result;
and receiving a remote service calling result returned by the proxy server to realize the calling of the remote service.
2. The method of claim 1, wherein obtaining the corresponding framework invocation code in response to the first invocation request comprises:
analyzing the first calling request, and determining a service identifier indicated by the first calling request;
acquiring a corresponding frame calling code from a preset file storage system according to the service identifier; or acquiring a service contract file from a preset file storage system according to the service identifier, and generating a frame calling code corresponding to the service identifier based on the service contract file.
3. The method of claim 2, further comprising:
the language type of the framework calling code is consistent with the language type of the first calling request.
4. The method of claim 2, after obtaining the corresponding framework invocation code, further comprising:
and implanting the framework calling code into client code.
5. The method of claim 2, wherein parsing the first invocation request further comprises: analyzing the first calling request to determine the access information indicated by the first calling request;
and generating a second call request to the proxy server by using the framework call code based on the first call request, wherein the second call request comprises:
performing serialized expression on the reference information by using the frame calling code; and generating a second calling request to the proxy server through a TCP (transmission control protocol) protocol based on the serialized expression result.
6. The method of claim 5, wherein enabling the proxy server to request and obtain the remote service invocation result from the service framework system according to the second invocation request through a TCP protocol comprises:
performing deserialization expression on the serialization expression result in the second call request by using the proxy server;
generating a third calling request for the remote service in the service framework system through a TCP (transmission control protocol) protocol by utilizing the proxy server based on the result of the deserialization expression;
and receiving the remote service calling result returned by the service framework system in response to the third calling request by utilizing the proxy server.
7. The method according to claim 6, before causing the proxy server to request and obtain the remote service invocation result from the service framework system according to the second invocation request through a TCP protocol, further comprising:
configuring a framework service code for the proxy server in advance based on the service contract file;
generating SPI interface data of a service producer called by a service consumer in the service framework system through Javaassist by utilizing the framework service code, and transmitting the SPI interface data into a development toolkit of the service framework system; and the number of the first and second groups,
generating, with the proxy server, a third invocation request for the remote service in the service framework system via a TCP protocol based on a result of the deserialization expression, including:
and adapting the result of the deserialization expression with the SPI interface data by using the proxy server to determine the service interface data of the remote service, and further generating the third calling request through a TCP (transmission control protocol) protocol based on the service interface data.
8. An apparatus for invoking a remote service, comprising:
the system comprises a receiving module, a frame calling module and a frame calling module, wherein the receiving module is used for receiving a first calling request for remote service and responding to the first calling request to acquire a corresponding frame calling code;
the calling module is used for generating a second calling request for the proxy server by utilizing the frame calling code based on the first calling request so that the proxy server requests a service frame system through a TCP protocol according to the second calling request and obtains a remote service calling result;
and the execution module is used for receiving a remote service calling result returned by the proxy server so as to realize the calling of the remote service.
9. An invoking electronic device of a remote service, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202110144183.4A 2021-02-02 2021-02-02 Remote service calling method and device Pending CN113821352A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110144183.4A CN113821352A (en) 2021-02-02 2021-02-02 Remote service calling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110144183.4A CN113821352A (en) 2021-02-02 2021-02-02 Remote service calling method and device

Publications (1)

Publication Number Publication Date
CN113821352A true CN113821352A (en) 2021-12-21

Family

ID=78912378

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110144183.4A Pending CN113821352A (en) 2021-02-02 2021-02-02 Remote service calling method and device

Country Status (1)

Country Link
CN (1) CN113821352A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115086420A (en) * 2022-06-16 2022-09-20 平安银行股份有限公司 Cross-domain request method and system and computer equipment
CN117278323A (en) * 2023-11-16 2023-12-22 荣耀终端有限公司 Third party information acquisition method, electronic equipment and readable storage medium
CN117270833A (en) * 2023-11-21 2023-12-22 支付宝(杭州)信息技术有限公司 Service calling and issuing method, medium and computer equipment
CN117278323B (en) * 2023-11-16 2024-04-19 荣耀终端有限公司 Third party information acquisition method, electronic equipment and readable storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115086420A (en) * 2022-06-16 2022-09-20 平安银行股份有限公司 Cross-domain request method and system and computer equipment
CN117278323A (en) * 2023-11-16 2023-12-22 荣耀终端有限公司 Third party information acquisition method, electronic equipment and readable storage medium
CN117278323B (en) * 2023-11-16 2024-04-19 荣耀终端有限公司 Third party information acquisition method, electronic equipment and readable storage medium
CN117270833A (en) * 2023-11-21 2023-12-22 支付宝(杭州)信息技术有限公司 Service calling and issuing method, medium and computer equipment
CN117270833B (en) * 2023-11-21 2024-04-26 支付宝(杭州)信息技术有限公司 Service calling and issuing method, medium and computer equipment

Similar Documents

Publication Publication Date Title
CN107967143B (en) Method, device and system for acquiring update indication information of source code of client application program
CN110324169B (en) Interface management method and device
CN111338623B (en) Method, device, medium and electronic equipment for developing user interface
CN111309375B (en) Method, device, medium and electronic equipment for generating remote procedure call toolkit
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN113760324A (en) Method and device for constructing micro front-end application
CN110888639A (en) Business code compiling and packaging method and device
CN113468067B (en) Application program debugging method and device, electronic equipment and computer readable medium
CN114500481A (en) Service request processing method, system and device
CN110807535A (en) Construction method and construction device of unified reservation platform and unified reservation platform system
CN113821352A (en) Remote service calling method and device
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN114398035A (en) Method, apparatus, device and computer readable medium for providing service using component
CN113779122B (en) Method and device for exporting data
CN115617420A (en) Application program generation method, device, equipment and storage medium
CN112905273A (en) Service calling method and device
CN112394907A (en) Container-based delivery system construction method, application delivery method and delivery system
CN112929453A (en) Method and device for sharing session data
CN112596729A (en) Target application interface generation method and device, readable medium and electronic equipment
CN112099841A (en) Method and system for generating configuration file
CN113779018A (en) Data processing method and device
CN112559001A (en) Method and device for updating application
CN112688863B (en) Gateway data processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination