Service calling method and device, equipment, storage medium and product
Through the service call method, the service party interface information is obtained, the calling scheme is determined, and the data format is converted, which solves the problem of inconsistent interface call data structure in the microservice architecture, and improves development efficiency and code maintenance.
Patent Information
- Application Number
- CN202410879474.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-10-15
AI Technical Summary
In the microservice architecture, when the interface between services is called, the data structures of the request method, request parameters and response body are inconsistent, resulting in low development efficiency, and the correct http request method and parameter encapsulation is required to deserialize the response body data, and Analyze adaptive business data.
A service call method is proposed. By receiving user requests, obtaining service interface information, determining the call scheme, calling service interface, converting data format, adapting to the data needed by the user, and sending it back to the user, simplifying the logic of service call , improves development efficiency.
The logic of service calls is extracted from the service provider and the user side, and the call scheme is selected by obtaining interface information and user information, data conversion is realized, development efficiency is improved, and code maintenance and adaptation logic is simplified.
Smart Images

Figure CN118779129A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a service invocation method, device, equipment, storage medium and product. Background Art
[0002] The backend service of the privacy computing platform adopts a service architecture to achieve high flexibility of the system. At the same time, with the help of mature frameworks such as dynamic naming and configuration service Nacos, it effectively solves key problems such as service discovery and configuration management in the microservice architecture.
[0003] In the related technology, services call interfaces through the http protocol, but when the services provided by the interface belong to different business contexts, the data structures of the interface's request method, request parameters, and response body are not consistent. Therefore, when calling the interface, the service consumer needs to use the correct http request method and parameter encapsulation method. Therefore, when receiving the response data, it is necessary not only to correctly deserialize the response body data, but also to parse the response body data structure according to the business context to which the interface belongs, and adapt and extract the business data that the consumer is concerned about, resulting in low efficiency during development. Summary of the invention
[0004] The main purpose of this application is to provide a service calling method, device, equipment, storage medium and product, aiming to solve the technical problem of low efficiency during development.
[0005] To achieve the above purpose, the present application proposes a service calling method, which includes:
[0006] Receiving a request sent by a user terminal, wherein the request includes user information;
[0007] Respond to the request and obtain service provider interface information;
[0008] Determine a calling scheme based on the interface information and the user information;
[0009] Based on the calling scheme, calling the service provider interface to obtain service data;
[0010] Based on the user information, convert the service data to obtain user data;
[0011] The user data is sent to the user terminal.
[0012] In one embodiment, the step of determining a calling scheme based on the user information and the service provider interface information includes:
[0013] The registered clusters of the user terminal and the service provider are judged. If the user terminal and the service provider are registered in the same cluster, the calling scheme is direct calling. If the user terminal and the service provider are registered in different clusters, the calling scheme is external routing calling.
[0014] In one embodiment, the step of responding to the request and obtaining service provider interface information includes:
[0015] In response to the request sent by the user terminal, the annotation information of the service provider interface is acquired to obtain the service provider interface information.
[0016] In one embodiment, the step of converting the service data based on the user information to obtain the user data includes:
[0017] Based on the user information, determine the user demand type;
[0018] Based on the user demand type, the service data is converted to obtain user data.
[0019] In one embodiment, the intermediate calling module includes a calling scheme unit and a data conversion unit, wherein the intermediate calling module is connected to the calling scheme unit and the data conversion unit via a bridging mode for independent management of the calling scheme unit and the data conversion unit.
[0020] In one embodiment, the intermediate call module defines a template method for service call through an abstract parent class, wherein the template method defines a hook method, the hook method is used to implement the call scheme unit and the data conversion unit, and the subclass of the abstract parent class is used to implement the hook method.
[0021] In addition, to achieve the above purpose, the present application also proposes a service calling device, the service calling device comprising:
[0022] A receiving module, used for receiving a request sent by a user terminal, wherein the request includes user information;
[0023] An acquisition module, used to respond to the request and acquire service provider interface information;
[0024] A scheme module, used for determining a calling scheme based on the interface information and the user information;
[0025] A calling module, used to call the service provider interface based on the calling scheme to obtain service data;
[0026] A conversion module, used to convert the service data based on the user information to obtain user data;
[0027] The sending module is used to send the user data to the user terminal.
[0028] In addition, to achieve the above objectives, the present application also proposes a service calling device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the service calling method described above.
[0029] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the service calling method described above are implemented.
[0030] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the service calling method described above are implemented.
[0031] One or more technical solutions proposed in this application have at least the following technical effects:
[0032] This application extracts the logic of service calls from the service provider and the user end, and only responds to the interfaces of the service provider and the user end. By obtaining the interface information of the service provider and calling the call scheme selected according to the interface information and user information, the data information is converted into the user data required by the user end and sent back to the user end, which improves the development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0035] Figure 1 A flowchart of the first embodiment of the method for calling a service of this application is provided;
[0036] Figure 2 This is the service call sequence diagram of the service call method of this application;
[0037] Figure 3 A service call topology diagram for the service call method of this application;
[0038] Figure 4 A routing strategy diagram for the service call method of this application;
[0039] Figure 5 The interface return parameter adaptation diagram of the service calling method of this application;
[0040] Figure 6 A dynamic proxy graph of the gateway for the service call method of this application;
[0041] Figure 7 This is a schematic diagram of the module structure of the service calling device in the embodiment of the present application;
[0042] Figure 8 A schematic diagram of the device structure of the hardware operating environment involved in the service calling method in the embodiment of the present application.
[0043] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0044] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0045] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0046] The main solution of the embodiment of the present application is: receiving a request sent by a user end, wherein the request includes user information; responding to the request, obtaining service party interface information; determining a calling scheme based on the interface information and the user information; based on the calling scheme, calling the service party interface to obtain service data; based on the user information, converting the service data to obtain user data; and sending the user data to the user end.
[0047] In the related technology, services call interfaces through the http protocol, but when the services provided by the interface belong to different business contexts, the data structures of the interface's request method, request parameters, and response body are not consistent. Therefore, when calling the interface, the service consumer needs to use the correct http request method and parameter encapsulation method. Therefore, when receiving the response data, it is necessary not only to correctly deserialize the response body data, but also to parse the response body data structure according to the business context to which the interface belongs, and adapt and extract the business data that the consumer is concerned about, resulting in low efficiency during development.
[0048] This application extracts the logic of service calls from the service provider and the user end, and only responds to the interfaces of the service provider and the user end. By obtaining the interface information of the service provider and calling the call scheme selected according to the interface information and user information, the data information is converted into the user data required by the user end and sent back to the user end, which improves the development efficiency.
[0049] It should be noted that the execution subject of this embodiment may be a service calling device, or a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a service calling device capable of realizing the above functions, etc. The following takes the service calling device as an example to illustrate this embodiment and the following embodiments.
[0050] Based on this, the embodiment of the present application provides a service calling device method, referring to Figure 1 , Figure 1 A flowchart of the first embodiment of the service calling method of this application is provided.
[0051] In this embodiment, Figure 2 It is a service call sequence diagram, which is applied to the intermediate call module. The service call method includes the following steps:
[0052] Step S100, receiving a request sent by a user terminal, wherein the request includes user information;
[0053] It should be noted that the request refers to the trigger instruction of the service call. User information refers to the parameters or data required for the service call. The device receives the request from the user end and obtains the information of the user end required for the service call. The core functions and interfaces of the device are designed as a shareable component or library (shared kernel). The shared kernel encapsulates basic functions related to service calls such as service discovery, load balancing, remote calls, serialization / deserialization, timeout processing, and retry logic. The interface declaration of the shared kernel defines how to define and implement the service interface so that the user end and the service end can interact in accordance with unified specifications. The shared kernel shares a set of basic devices or components. All microservices that make service calls can directly reuse this set of infrastructure without each service having to implement these basic functions separately, thereby reducing duplication of work and improving the maintainability and consistency of the code. The device publishes the service call function and interface declaration in the form of a shared kernel. The user end introduces the shared kernel dependency to obtain the out-of-the-box service call function. The device publishes the service call framework in the form of a shared kernel, which not only promotes efficient collaboration between services, but also greatly improves the development efficiency and maintainability of the system through standardized and componentized design.
[0054] Step S200, responding to the request and obtaining service provider interface information;
[0055] It is understandable that the service provider interface information refers to the protocol, routing method, input parameters and return parameters of the service provider interface. When the device responds to the call request from the user, it obtains the message from the service provider interface. The service provider exposes a standardized and unified Java interface to the user. The service provider publishes the interface declaration through a jar package, and the interface declaration declares the various parameters of the interface descriptor through annotations.
[0056] The device provides a mechanism to pass the interface protocol, routing, input and output parameter information to the interface call implementation class at runtime. The interface descriptor is the carrier to implement this mechanism. The interface descriptor is a declaration of the service interface that the service provider needs to expose. It is the basis for routing strategy selection, interface response data adaptation, and interface call implementation class bridging. The default configuration of the interface descriptor is written in the code. The content of the interface descriptor can be adjusted through environment variables at runtime, thereby changing the routing strategy when the interface is called.
[0057] The interface descriptor contains the following:
[0058] Protocol: specifies the communication protocol used for service interaction, such as http, grpc, etc.
[0059] Service name (hostname): A unique name that identifies a service and is used for service discovery and routing.
[0060] Routing type: defines the routing strategy used when calling the service, such as weight-based, random, polling, etc.
[0061] Path: In HTTP service, it refers to the URL path part of the service.
[0062] HTTP request method: one of the HTTP request methods such as get, post, put, delete, etc.
[0063] Request parameter type: describes the format or type of the request data, such as json, xml, etc.
[0064] Return data type: defines the data format or type of the service response.
[0065] Returns the data deserialization method. Indicates how to convert the received data into a Java object, such as using libraries such as Jackson and Gson.
[0066] Step S300, determining a calling scheme based on the interface information and the user information;
[0067] It should be noted that the calling scheme refers to the routing scheme. The routing scheme for service calling is selected based on the interface information and user information.
[0068] In a feasible implementation manner, the above steps further include the following steps:
[0069] The registered clusters of the user terminal and the service provider are judged. If the user terminal and the service provider are registered in the same cluster, the calling scheme is direct calling. If the user terminal and the service provider are registered in different clusters, the calling scheme is external routing calling.
[0070] It is understandable that the device implements service calls through the privacy computing platform. The privacy computing platform is a computing framework that uses a series of advanced technologies to achieve data privacy protection. These technologies allow data to be analyzed and calculated without being directly disclosed. The choice of service call routing strategy is determined by the registration status of the service provider and the user end, and is specifically divided into two scenarios: When the user end calls the service interface, if the service provider and the user end are registered to the same Nacos cluster, the device can call through the Nacos service. As a service registration and discovery center, Nacos can perceive the online and offline status of service instances in real time, thereby realizing intelligent load balancing and service routing. If the service provider and the user end are not registered to the same Nacos cluster, the system uses a reverse proxy to make the call. As an intermediate layer, the reverse proxy can hide the actual location of the service, provide additional security, load balancing, and protocol conversion functions. The service call topology diagram is shown below. Figure 3 As shown. Therefore, the privacy computing platform uses the policy pattern to implement the routing plan when calling. Each service interface in the device may have a unique identifier (interface descriptor), which may contain the name, version number or other metadata information of the service. The routing policy selector determines the most appropriate routing plan based on this descriptor. As the context in the policy pattern, the routing policy selector dynamically selects the most appropriate routing strategy (i.e., algorithm) to execute the service call logic based on the current runtime environment and interface descriptor before the service is called. In this way, when the service architecture or network environment changes, only new or modified policies need to be added, without changing the main logic of the service call. The routing selection strategy diagram is shown in Figure 4 shown.
[0071] Step S400, based on the calling scheme, calling the service provider interface to obtain service data;
[0072] It should be noted that service data refers to the service provider's interface response data. The device calls the service provider's interface according to the selected calling scheme and obtains the service provider's interface response data. The interfaces exposed by the backend application of the privacy computing platform are all http interfaces, and the response http header field Content-Type mainly has two categories: application / json and application / octet-stream.
[0073] For interfaces whose Content-Type is application / json, the device can be further divided into different types from the business dimension, and the data structure of the response body is associated with the business context to which the interface belongs. The device provides a business data adaptation solution for the commonly used business contexts of the privacy computing platform, and the user end can also implement the data adaptation interface to customize the business data adaptation logic.
[0074] Step S500, based on the user information, convert the service data to obtain user data;
[0075] It is understandable that user data refers to the data required by the user end. The device automatically converts the data format according to the return format and requirements of different services to ensure that service consumers can receive expected results. This can avoid the service caller from directly dealing with various complex adaptation logics, thereby improving the reusability and maintainability of the code. Based on the type interface of the response Content-Type, the device adapts the service data to the user data required by the user end. For interfaces whose response Content-Type is application / json type, no matter what data structure, what the user end really needs is the data in the data field, that is, the business DTO. For interfaces whose response Content-Type is application / octet-stream type, what the user end needs is a binary stream, that is, InputStream. In the face of the above application scenarios, the privacy computing platform adopts the adapter mode to adapt the service party's interface response data to DTO or InputStream according to the interface descriptor. The interface return parameter adaptation diagram is shown in the figure below. Figure 5 shown.
[0076] Step S600: sending the user data to the user terminal.
[0077] It should be noted that the device sends the adapted user data to the user end to implement service calling.
[0078] This embodiment provides a service calling method, which extracts the service calling logic from the service party, publishes the service calling function and interface declaration in a shared kernel manner, obtains the service party interface information by the device responding to the request sent by the user end, and selects the corresponding routing scheme to make a service call based on the service party's interface information to obtain the service data. After that, the device adapts the service data to the data required by the user end, thereby improving development efficiency.
[0079] In a feasible implementation manner, the service calling method further includes the following steps:
[0080] The intermediate calling module includes a calling scheme unit and a data conversion unit, wherein the intermediate calling module is connected with the calling scheme unit and the data conversion unit through a bridge mode to independently manage the calling scheme unit and the data conversion unit.
[0081] It should be noted that the intermediate call module refers to the service call device. The bridge mode refers to a reference mode, the main purpose of which is to separate the abstract part from its implementation part so that it can change independently. The call scheme unit refers to the routing scheme strategy selector used to implement the call scheme selection, and the data conversion unit refers to the return parameter adapter for the response parameter adaptation. The interfaces exposed by the service party in the device are encapsulated into Java interfaces with the suffix Gateway. These interfaces act as service contracts, define the input and output parameters of the service and the service behavior, but do not involve specific implementation details. This design method separates the definition and implementation of the service, and improves the maintainability and scalability of the service. In the privacy computing platform, this type of interface is called a service gateway interface. The implementation class of the service gateway interface does not directly write specific business logic, but is completed through a dynamic proxy mechanism. The role of the dynamic proxy here is to dynamically select and execute the corresponding logic according to the interface call, including service discovery, routing selection, request forwarding, response processing, etc. Each method in the interface corresponds to an http interface of the service provider. The service provider converts the business logic interface into a form that can be remotely called through the dynamic proxy. This means that the caller of the service does not need to understand the details of the service implementation, but only needs to program according to the declared interface. The dynamic proxy creates a proxy object in this process, which automatically executes the remote call logic according to the configuration when called, such as sending a request to the service provider through the network and receiving the response result. The Spring Boot framework uses the Service Provider Interface (SPI) mechanism to allow the device to automatically discover and assemble related components in the form of plug-ins. This means that developers do not need to manually configure the details of each service call, but use the framework's automatic configuration capabilities to automatically assemble the dynamic proxy implementation code required for the service call according to the project's dependencies and configuration. This mechanism greatly simplifies the initialization and configuration process of the service call. The implementation class of the service gateway interface is implemented through a dynamic proxy. The implementation class combines the routing plan strategy selector and the return parameter adapter through the bridge mode, and uses the dynamic proxy mode to implement the declarative interface exposed by the service provider. The SpringBoot SPI mechanism is used to automatically assemble the dynamic proxy implementation code, select the routing plan when calling the service through environment variables, and adapt the return parameter service call method. The gateway dynamic proxy diagram is as follows Figure 6 shown.
[0082] In a feasible implementation manner, the above steps further include the following steps:
[0083] The intermediate call module defines a template method for service call through an abstract parent class, wherein the template method defines a hook method, the hook method is used to implement the call scheme unit and the data conversion unit, and the subclass of the abstract parent class is used to implement the hook method.
[0084] It is understandable that an abstract parent class is designed to provide a base class for other subclasses to inherit, and usually contains some abstract methods and specific implementation methods. A hook method is to provide an optional intervention point for a subclass, allowing the subclass to override or extend the behavior of the base class without destroying the algorithm structure defined by the template method.
[0085] All implementation classes of strategies, adapters, and bridges in the device indirectly implement interfaces through abstract parent classes. A template method is defined in the abstract parent class. The template method refers to the stock price of a specific sequence of operation steps. The method defines the structure or execution process of the algorithm. These specific operation steps (hooks) are implemented by subclasses. Some abstract methods or default hook methods are called inside the template method. Hook methods do not have specific implementations or provide default behaviors. Subclasses can override them as needed to add specific logic to achieve behavioral diversity. Abstract parent classes can also contain some specific methods that encapsulate common functions for reuse by all subclasses. This can reduce code duplication.
[0086] In the device, different business logics are regarded as different strategies. Each specific strategy class can inherit from the abstract parent class and implement the corresponding hook method. The template method in the abstract parent class is responsible for calling these strategies, so that the code using these strategies does not need to be modified when the strategies are dynamically switched. In the context of the abstract parent class, if there are external interfaces or classes that need to be adapted, one or more adapter subclasses can be defined. These subclasses inherit from the abstract parent class and implement the necessary conversion logic, so that the originally incompatible classes can meet the interface requirements defined by the abstract parent class.
[0087] In the abstract parent class: implement the template method to arrange unified business logic for the subclass; define the hook method in the template method, implement the hook method in the subclass to provide personalized functions; provide methods that can be reused by subclasses to reduce repeated development.
[0088] This embodiment provides a service calling method. This embodiment separates the abstract part of the service from the implementation function of the service through a bridge pattern to facilitate independent management, and defines a set of common service calling interfaces and some common template methods for implementing logic through an abstract parent class. The structure of the service call becomes clearer, easier to understand and maintain, and the development efficiency is improved through the application of the bridge pattern and the abstract parent class.
[0089] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the service calling method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0090] This application also provides a service calling device, please refer to Figure 7 , the service calling device comprises:
[0091] The receiving module 10 is used to receive a request sent by a user terminal, wherein the request includes user information;
[0092] The acquisition module 20 is used to respond to the request and acquire the service provider interface information;
[0093] A solution module 30, configured to determine a calling solution based on the interface information and the user information;
[0094] A calling module 40, configured to call the service provider interface based on the calling scheme to obtain service data;
[0095] A conversion module 50, configured to convert the service data based on the user information to obtain user data;
[0096] The sending module 60 is used to send the user data to the user terminal.
[0097] Optionally, the solution module is also used to:
[0098] The registered clusters of the user terminal and the service provider are judged. If the user terminal and the service provider are registered in the same cluster, the calling scheme is direct calling. If the user terminal and the service provider are registered in different clusters, the calling scheme is external routing calling.
[0099] Optionally, the acquisition module is further used for:
[0100] In response to the request sent by the user terminal, the annotation information of the service provider interface is acquired to obtain the service provider interface information.
[0101] Optionally, the conversion module is further used for:
[0102] Based on the user information, determine the user demand type;
[0103] Based on the user demand type, the service data is converted to obtain user data.
[0104] The service calling device provided by the present application adopts the service calling method in the above embodiment, which can solve the technical problem of service calling. Compared with the prior art, the beneficial effects of the service calling device provided by the present application are the same as the beneficial effects of the service calling method provided by the above embodiment, and other technical features in the service calling device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0105] The present application provides a service calling device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the service calling method in the above-mentioned embodiment 1.
[0106] Reference below Figure 8 , which shows a schematic diagram of the structure of a service invocation device suitable for implementing an embodiment of the present application. The service invocation device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The service calling device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0107] like Figure 8As shown, the service calling device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the service calling device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the service calling device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a service calling device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0108] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0109] The service calling device provided by the present application adopts the service calling method in the above embodiment to solve the technical problem of service calling. Compared with the prior art, the beneficial effects of the service calling device provided by the present application are the same as the beneficial effects of the service calling method provided by the above embodiment, and the other technical features in the service calling device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0110] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0111] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0112] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the service calling method in the above-mentioned embodiment.
[0113] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0114] The computer-readable storage medium may be included in the service calling device; or may exist independently without being assembled into the service calling device.
[0115] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the service calling device, the service calling device: receives a request sent by the user end, wherein the request includes user information; responds to the request and obtains the service party interface information; determines a calling scheme based on the interface information and the user information; based on the calling scheme, calls the service party interface to obtain service data; based on the user information, converts the service data to obtain user data; and sends the user data to the user end.
[0116] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0117] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0118] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0119] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned service calling method, and can solve the technical problem of service calling. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the service calling method provided by the above-mentioned embodiment, and will not be repeated here.
[0120] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned service calling method when executed by a processor.
[0121] The computer program product provided by this application can solve the technical problem of service calling. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the service calling method provided by the above embodiment, which will not be repeated here.
[0122] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A service calling method, characterized in that: Applied to the intermediate calling module, the service calling method includes: Receiving a request sent by a user terminal, wherein the request includes user information; Respond to the request and obtain service provider interface information; Determine a calling scheme based on the interface information and the user information; Based on the calling scheme, calling the service provider interface to obtain service data; Based on the user information, convert the service data to obtain user data; The user data is sent to the user terminal.
2. The service calling method according to claim 1, characterized in that: The step of determining the calling scheme based on the interface information and the user information comprises: The registered clusters of the user terminal and the service provider are judged. If the user terminal and the service provider are registered in the same cluster, the calling scheme is direct calling. If the user terminal and the service provider are registered in different clusters, the calling scheme is external routing calling.
3. The service calling method according to claim 1, characterized in that: The step of obtaining service provider interface information in response to the request includes: In response to the request sent by the user terminal, the annotation information of the service provider interface is acquired to obtain the service provider interface information.
4. The service calling method according to claim 1, characterized in that: The step of converting the service data based on the user information to obtain the user data comprises: Based on the user information, determine the user demand type; Based on the user demand type, the service data is converted to obtain user data.
5. The service calling method according to claim 1, characterized in that: The intermediate calling module includes a calling scheme unit and a data conversion unit, wherein the intermediate calling module is connected with the calling scheme unit and the data conversion unit through a bridge mode to independently manage the calling scheme unit and the data conversion unit.
6. The service calling method according to claim 5, characterized in that: The intermediate call module defines a template method for service call through an abstract parent class, wherein the template method defines a hook method, the hook method is used to implement the call scheme unit and the data conversion unit, and the subclass of the abstract parent class is used to implement the hook method.
7. A service calling device, characterized in that: The device comprises: A receiving module, used for receiving a request sent by a user terminal, wherein the request includes user information; An acquisition module, used to respond to the request and acquire service provider interface information; A scheme module, used for determining a calling scheme based on the interface information and the user information; A calling module, used to call the service provider interface based on the calling scheme to obtain service data; A conversion module, used to convert the service data based on the user information to obtain user data; The sending module is used to send the user data to the user terminal.
8. A service calling device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the service invocation method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the service calling method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the service calling method according to any one of claims 1 to 6 are implemented.
