Data calling method, device and equipment and computer readable storage medium
By encapsulating a unified outbound call component and data converter, the problems of redundant code and poor reusability in existing technologies are solved, enabling a flexible and efficient data calling process and simplifying development and maintenance.
Patent Information
- Application Number
- CN202511407861.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2025-12-30
AI Technical Summary
Existing technologies suffer from redundant code and poor reusability of development processes when calling external data, especially when requirements change, which can easily lead to errors and repeated development.
By encapsulating a unified outbound call component, a data converter is used to convert information entity classes into extended markup language messages, which are then sent to the target end through a general call interface. This achieves a standard, reusable message conversion mechanism, reducing manual maintenance and repetitive coding.
It simplifies the development process, reduces code redundancy, improves development efficiency and consistency, and reduces operational complexity and costs.
Smart Images

Figure CN121239751A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of data processing, and particularly relates to a data calling method and device, equipment and a computer readable storage medium. BACKGROUND
[0002] In the process of performing a service, external data can be obtained by calling an outbound interface to complete the service. Specifically, the existing calling of external data usually includes receiving a data calling request sent by a calling information end, controlling layer receiving the request and sending it to a service layer, the service layer performing outbound interface calling, specifically, an entity class and an Extensible Markup Language (XML) configuration file are written by using freemarker to generate an XML message, and the XML message is sent to a target end to obtain data and returned to the calling information end.
[0003] However, the foregoing calling method has a large amount of redundant code and development process, and has poor reusability.
[0004] Based on this, the present application provides a data calling method. SUMMARY
[0005] The embodiments of the present application provide a data calling method, device, equipment, computer readable storage medium and computer program product, which can adapt to the diversified needs of different service scenarios and improve the flexibility of data calling.
[0006] In a first aspect, the embodiments of the present application provide a data calling method, which is applied to a server, and the method comprises: obtaining a data calling request forwarded by a routing layer of the server, wherein the data calling request includes an information entity class and a target service code; wherein the data calling request is forwarded to the target service layer of the server after the routing layer determines the target service layer corresponding to the target service code in a plurality of service layers according to the target service code and a first corresponding relationship between the service layer and the service code which is set in advance; based on the target service code, calling an outbound component to receive response information returned by a target end, wherein the target end is a data storage party storing data requested to be called by a data calling party, wherein the outbound component includes a data converter and a general calling interface, the data converter is used to convert the information entity class into an Extensible Markup Language (XML) message, and the general calling interface is used to send the XML message to the target end based on an outbound identifier of configuration information required by the target service layer obtained based on the target service code; sending the response information to the data calling party.
[0007] In a possible implementation, based on the target service code, a calling-out component is invoked to receive response information returned by the target end, and specifically includes the following steps: Based on the target service code, a calling-out identifier of configuration information required by the target service layer for calling out is determined; According to the calling-out identifier, a data converter in the calling-out component is invoked to convert the information entity class into an extended markup language message; The extended markup language message is sent to the target end by invoking a general calling interface in the calling-out component; Response information returned by the target end is received.
[0008] In a possible implementation, according to the calling-out identifier, a data converter in the calling-out component is invoked to convert the information entity class into an extended markup language message, and specifically includes the following steps: According to the calling-out identifier and a second correspondence relationship between the identifier and configuration information stored in advance, target extended markup language annotation configuration information is obtained, the configuration information including a conversion relationship between an entity class called by each data calling request and the extended markup language; According to the target extended markup language annotation configuration information, the data converter in the calling-out component is invoked to perform data conversion on the information entity class, to obtain an extended markup language message.
[0009] In a possible implementation, the extended markup language message is sent to the target end by invoking a general calling interface in the calling-out component, and specifically includes the following steps: According to the calling-out identifier and a third correspondence relationship between the identifier and a general calling interface stored in advance, a first general calling interface is determined; The first hypertext transfer protocol client is invoked through the first general calling interface, so that the first hypertext transfer protocol client calls a calling-out interface corresponding to the first general calling interface, and sends the extended markup language message and a target service code corresponding to the extended markup language message to the target end.
[0010] In a possible implementation, the extended markup language message is sent to the target end by invoking a general calling interface in the calling-out component, and specifically includes the following steps: The second hypertext transfer protocol client is invoked through the second general calling interface, so that the second hypertext transfer protocol client calls a calling-out interface corresponding to the calling-out identifier, and sends the extended markup language message and a target service code corresponding to the extended markup language message to the target end.
[0011] In one possible implementation, the response information includes an Extended Markup Language (EML) response message. The response information is obtained by the target end from the information interface through a dynamic addressing method, based on the EML message and the target service code corresponding to the EML message, to retrieve the information required by the data caller.
[0012] In one possible implementation, before sending the response information to the data caller, the method further includes: By calling the data converter in the outbound call component, the response information is converted according to the target extended markup language annotation configuration information to obtain the target entity class. The target extended markup language annotation configuration information is in tabular form.
[0013] In one possible implementation, sending the response information to the data caller specifically includes: The target entity class is encapsulated to obtain the encapsulation result; The encapsulation result is sent to the data caller.
[0014] Secondly, embodiments of this application provide a data retrieval system, the system comprising a routing component and a target service component, wherein: The routing component is used to receive a data call request sent by a data caller. The data call request includes an information entity class and a target service code. Based on the target service code and a pre-set first correspondence between service components and service codes, the component corresponding to the target service code is determined, and the data call request is sent to the target service component. The target service component is used to receive response information returned by the target end by calling the outbound call component based on the target service code, and send the response information to the data caller. The target end is a data storage provider that stores the data requested by the data caller. The outbound call component includes a data converter and a general call interface. The data converter is used to convert the information entity class into an extended markup language message. The general call interface is used to send the extended markup language message to the target end based on the outbound call identifier of the configuration information required for the outbound call of the target service component obtained by the target service code.
[0015] Thirdly, embodiments of this application provide a data retrieval device, which includes: The data call request acquisition module is used to acquire data call requests forwarded by the routing layer of the server. The data call request includes an information entity class and a target service code. The data call request is forwarded to the target service layer of the server by the routing layer after determining the target service layer corresponding to the target service code from among several service layers based on the target service code and a pre-set first correspondence between service layers and service codes. The outbound call module is used to receive response information returned by the target end by calling the outbound call component based on the target service code. The target end is a data storage provider that stores the data requested by the data caller. The outbound call component includes a data converter and a general call interface. The data converter is used to convert the information entity class into an extended markup language message. The general call interface is used to send the extended markup language message to the target end based on the outbound call identifier of the configuration information required for the target service layer outbound call obtained from the target service code. The response information sending module is used to send the response information to the data caller.
[0016] Fourthly, embodiments of this application provide an electronic device, the device including: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements any one of the possible implementations of the first aspect described above.
[0017] Fifthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement any of the possible implementation methods in the first aspect described above.
[0018] In a sixth aspect, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform any of the possible implementation methods described in the first aspect above.
[0019] The data retrieval method, apparatus, device, computer-readable storage medium, and computer program product of this application embodiments receive a data retrieval request sent by a data retrieval party. The data retrieval request includes an information entity class and a target service code. Based on the target service code, an outbound call component is invoked to receive response information returned by the target end. The target end is a data storage provider storing the data requested by the data retrieval party. The outbound call component includes a data converter that converts the information entity class into an Extended Markup Language (EML) message and an outbound call identifier containing configuration information required for the target service layer outbound call based on the target service code. The EML message is sent to the target end, and the response information is sent to the general call interface of the data retrieval party. By encapsulating a unified outbound call component for outbound calls, this unified outbound call component can be reused, eliminating the need for repeated development based on specific data, simplifying the development process, and reducing code redundancy. Since the message structure of the request and response is different for each different data, a data converter is used to provide a standard, reusable message conversion mechanism. There is no need to manually maintain the relationship between each XML and entity class, reducing the need for manual rewriting of messages, thereby reducing a large amount of redundant code and development processes. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A schematic diagram of the internal structure of a server provided in an embodiment of this application; Figure 2 A flowchart illustrating a data retrieval method provided in an embodiment of this application; Figure 3 A flowchart illustrating another data retrieval method provided in an embodiment of this application; Figure 4 This application provides a schematic diagram of an outbound call process. Figure 5 This is a schematic diagram of a third correspondence provided in an embodiment of this application; Figure 6 This application provides a schematic diagram of a general API call. Figure 7 This is a schematic diagram of the structure of a data retrieval device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0022] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0023] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0024] Furthermore, the acquisition, storage, use, and processing of data in this application's technical solution all comply with relevant national laws and regulations.
[0025] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, they do not mean that the applicant has used or necessarily used the solution.
[0026] Currently, data retrieval involves writing entity classes and XML configuration files using FreeMarker, followed by outbound call interface development, service layer interface development for outbound call calls, and finally, a controller layer interface to call the service layer. Since entity classes and XML configuration files are essentially two expressions of the same data contract, any change in requirements, such as adding a field, requires users to modify both entity classes and XML configuration files simultaneously. This is highly prone to omissions, leading to runtime errors such as XML parsing failures or missing fields. Furthermore, users have found that the development process for each outbound call interface is highly similar, resulting in a large amount of duplicate code in the service layer, such as repeatedly writing code for HyperText Transfer Protocol (HTTP) client calls, exception handling, and logging. Users can be technical personnel, planners, developers, or anyone else who develops the data retrieval process.
[0027] To address the problems of existing technologies, embodiments of this application provide a data retrieval method, apparatus, device, computer-readable storage medium, and computer program product. The method involves receiving a data retrieval request from a data retrieval party, the request including an information entity class and a target service code. Based on the target service code, an outbound call component is invoked to receive response information returned by the target end. The target end is a data storage provider storing the data requested by the data retrieval party. The outbound call component includes a data converter that converts the information entity class into an Extended Markup Language (EML) message and an outbound call identifier containing configuration information required for the target service layer outbound call based on the target service code. The EML message is sent to the target end, and the response information is sent to a general call interface of the data retrieval party. By encapsulating a unified outbound call component, the outbound call can be reused, eliminating the need for repeated development based on specific data, simplifying the development process, and reducing code redundancy. Since the message structures of requests and responses differ for each different data, a data converter is used to provide a standard, reusable message conversion mechanism. The method eliminates the need for manual maintenance of the relationships between each XML and entity class, reducing the manual rewriting of messages and thus reducing a large amount of redundant code and development processes.
[0028] The data retrieval method provided in the embodiments of this application is described below. The execution subject of the embodiments of this application can be a server used for data retrieval. The server includes a routing layer and several service layers.
[0029] Figure 1 A schematic diagram of the internal structure of a server provided in this application embodiment is shown below. Figure 1 As shown.
[0030] The server includes a routing layer and several service layers. This application embodiment does not limit the number of service layers. The routing layer sends each data call request to the corresponding service layer, and the service layers execute the data call tasks.
[0031] Figure 2 This is a flowchart illustrating a data retrieval method provided in an embodiment of this application, as shown below. Figure 2 As shown, the data retrieval method packages S201~S203 provided in this application embodiment are as follows: S201: Obtain the data call request forwarded by the routing layer of the server, wherein the data call request includes an information entity class and a target service code.
[0032] S202: Based on the target service code, the outbound call component is invoked to receive the response information returned by the target terminal.
[0033] S203: Send the response information to the data caller.
[0034] The data retrieval method in this application embodiment receives a data retrieval request sent by a data retrieval party. The data retrieval request includes an information entity class and a target service code. Based on the target service code, an outbound call component is invoked to receive response information returned by the target end. The target end is a data storage provider storing the data requested by the data retrieval party. The outbound call component includes a data converter that converts the information entity class into an Extended Markup Language (EML) message and an outbound call identifier containing the configuration information required for the target service layer outbound call based on the target service code. The EML message is sent to the target end, and the response information is sent to the general call interface of the data retrieval party. By encapsulating a unified outbound call component for outbound calls, this unified outbound call component can be reused, eliminating the need for repeated development based on specific data, simplifying the development process, and reducing code redundancy. Since the message structure of the request and response is different for each different data, a data converter is used to provide a standard, reusable message conversion mechanism. There is no need to manually maintain the relationship between each XML and entity class, reducing the need for manual rewriting of messages, thereby reducing a large amount of redundant code and development processes.
[0035] Figure 3 A flowchart illustrating another data retrieval method provided in this application embodiment is shown below. Figure 3 As shown.
[0036] The data retrieval request is forwarded to the server by the routing layer after determining the target service layer corresponding to the target service code among several service layers based on the target service code and the pre-set first correspondence between service layers and service codes.
[0037] The data caller can send a data call request to the server's routing layer. The routing layer then forwards the request to the corresponding service layer. The service layer invokes an outbound call component, enabling the target to return a response, which is then sent back to the data caller. The data caller can be any electronic device with a call requirement, and the data it calls can be any business data, such as transaction data; this embodiment does not impose any limitations on this. The service layer is a service unit within the backend server responsible for specific business operations. It may include a user service layer for handling user registration, login, and information queries, and an order service layer for handling order creation, querying, and payment. The target is the data storage provider that stores the data requested by the data caller. It is understood that since the requested data may reside in different storage providers, multiple target devices are possible.
[0038] The specific implementation methods for each of the above steps are described below.
[0039] In some embodiments, in S201, the information entity class is the entity class of the data to be called by the data caller, and the service code is the code corresponding to the called data, which can be understood as the unique identifier of the called data.
[0040] Understandably, since there are multiple service layers, in order to facilitate the routing layer in determining which service layer can execute the data call task for the data required in each data call request, a first correspondence between the service code and the service layer is set in advance. When the routing layer receives a data call request, it can determine the target service layer for executing the data call business based on the target service code included in the data call request and the pre-set first correspondence.
[0041] In some embodiments, in S202, it should be noted that the outbound call component includes a data converter and a general calling interface. The data converter is used to convert information entity classes into extended markup language messages, and the general calling interface is used to send extended markup language messages to the target end based on the outbound call identifier of the configuration information required for outbound calls of the target service layer obtained by the target service encoding.
[0042] It is understood that this application embodiment encapsulates a unified outbound call component, enabling all service layers to invoke external interfaces and obtain response information by calling this component. When new data arrives, users only need to define annotated entity classes and add the service code and related correspondences of the new data to the configuration information, significantly reducing user-involved operations and redundant code, thereby improving development efficiency and consistency.
[0043] In some embodiments, Figure 4This application provides a schematic diagram of an outbound call process, as shown in the embodiments of the present application. Figure 4 As shown.
[0044] When the target service layer calls the outbound call component, it determines the outbound call identifier of the configuration information required for the outbound call based on the target service code; according to the outbound call identifier, it converts the information entity class into an extended markup language message by calling the data converter in the outbound call component; it sends the extended markup language message to the target end by calling the general call interface in the outbound call component; and it receives the response information returned by the target end.
[0045] Since the message structures of each different data call request and response are different, without a unified mechanism, corresponding parsing and assembly code needs to be written for each piece of data, greatly increasing the user's workload. From a code perspective, for the outbound call component, designing only one outbound call component is sufficient to implement calls to all places that require them. From a business implementation perspective, this unified outbound call component, through configuration, has the ability to call countless different external services. Furthermore, in a microservice cluster, each microservice instance runs an instance of this component.
[0046] The purpose of a data converter is to provide a standard, reusable message conversion mechanism. By developing a universal data converter, regardless of the entity class input, it can convert that entity class into an XML message. This eliminates the need for users to write code for each piece of data, reducing their workload. Consequently, when new data appears, users no longer need to rewrite the code for message parsing; they can simply define a new entity class and add the appropriate annotations. The data converter only needs to be developed once throughout the entire system lifecycle, and all data conversions can use the same data converter, enabling repeated calls.
[0047] It should be noted that the outbound call component also includes a request interceptor and a log factory. The request interceptor is used to intercept and process requests, and the log factory is used to configure relevant logging information.
[0048] Understandably, during data conversion, the service layer can also obtain the target extended markup language annotation configuration information based on the outbound call identifier and the second correspondence between the pre-stored identifier and configuration information. The configuration information includes the conversion relationship between the entity class called by each data call request and the extended markup language. By calling the data converter in the outbound call component, the information entity class is converted according to the target extended markup language annotation configuration information to obtain the extended markup language message.
[0049] The data converter may include a JAXB (Java Architecture for XML Binding) encoder and a JAXB decoder. When converting entity classes into XML messages, the JAXB encoder can convert the information entity classes into XML messages based on the target XML annotation configuration information.
[0050] To facilitate the identification of the general call interface and the conversion rules for data transformation during outbound calls, a pre-defined mapping between service codes and outbound call identifiers for the required configuration information is established. Each outbound call identifier is configured with corresponding data transformation rules and a target endpoint. Therefore, during an outbound call, the corresponding configuration information can be obtained through the mapping between service codes and outbound call identifiers to perform data transformation.
[0051] In other words, by setting a mapping between outbound call identifiers and configuration information, the service layer can retrieve richer configurations based on the outbound call identifier when making an outbound call. This includes information such as which generic API to use, the conversion relationship between entity classes and XML fields, and the required parameters. This mapping decouples service coding from the generic API being called, improving flexibility.
[0052] For example, the same business operation, such as querying user A's credit, might require calling different external services due to different scenarios, such as differences between internal review and external compliance. In this case, the outbound call identifier can be flexibly configured without modifying the code. Alternatively, when the external service interface changes, only the configuration of the outbound call identifier needs to be adjusted, without modifying the business logic.
[0053] By extracting all outbound call variables into a configuration file, each data item is associated with a unique identifier, enabling the extraction of configuration information. When needed, configuration parameters are managed holistically by calling the outbound call identifier. A unified outbound call component is implemented, providing a unified and configurable technical outbound call pipeline.
[0054] In some embodiments, when calling a general calling interface, a first general calling interface can be determined based on the outbound call identifier and a pre-stored third correspondence between the identifier and the general calling interface; through the first general calling interface, a first Hypertext Transfer Protocol client is called, so that the first Hypertext Transfer Protocol client calls the outbound call interface corresponding to the first general calling interface to send the Extended Markup Language (EML) message and the target service code corresponding to the EML message to the target end.
[0055] Figure 5 A schematic diagram of a third correspondence provided in an embodiment of this application, such as... Figure 5 As shown.
[0056] 1-6 are service codes. Outbound call 1 and outbound call 2 are outbound call identifiers. Outbound call 1 can correspond to service codes 1-3 and corresponds to the first general call interface 1. Outbound call 2 can correspond to service codes 4-6 and corresponds to the first general call interface 2.
[0057] In other words, one outbound call identifier can correspond to multiple service codes, and one outbound call identifier can correspond to one first general-purpose call interface. Therefore, one first general-purpose call interface can correspond to multiple service codes. For each first general-purpose call interface, when the service layer calls this first general-purpose call interface, the outbound call interface used by the first HTTP client called by this first general-purpose call interface is fixed. This fixed correspondence eliminates the need for an intermediate layer between the outbound call layer and the first general-purpose call interface, improving development efficiency.
[0058] It's important to note that the general calling interface can be the Feign interface. When using the Feign interface, during configuration, a Java interface is defined, and annotations are used to declare which remote HTTP client this interface should map to. The Feign interface will automatically implement the logic for sending HTTP requests at runtime based on the interface definition. The HTTP client is the client defined to send the request; related configurations may include ReadTimeout, ConnectTimeout, etc. ReadTimeout and ConnectTimeout are behavioral rules configured for the HTTP client, specifying the maximum waiting time for the HTTP client to initiate a network request. If this maximum waiting time is exceeded, the client will abandon the wait. The specific Feign interface can be configured to obtain the corresponding HTTP client, which then sends the XML message along with the appropriate target service encoding to the target endpoint.
[0059] Because Feign integrates Ribbon by default, providing load balancing capabilities for HTTP clients, Feign will automatically select an instance for invocation. Furthermore, it can integrate circuit breakers such as Hystrix or Sentinel to add fault tolerance to service calls and prevent cascading failures.
[0060] This application embodiment uses the declarative web service client framework Feign combined with the JAXB framework, combining XML files with JSON objects to simplify the process of writing HTTP clients, making the application programming interface (API) definition clearer and easier to understand, and increasing code readability.
[0061] In other embodiments, the target service layer may also invoke a second Hypertext Transfer Protocol client through a second general call interface, so that the second Hypertext Transfer Protocol client invokes the outbound call interface corresponding to the outbound call identifier to send the Extended Markup Language (EML) message and the target service code corresponding to the EML message to the target end.
[0062] Figure 6 This application provides a schematic diagram of a general API call, as shown in the embodiment of the application. Figure 6 As shown.
[0063] Service codes 1-6 are used for outbound calls, while outbound call 1 and outbound call 2 are outbound call identifiers. Outbound call 1 can correspond to service codes 1-3, and outbound call 2 can correspond to service codes 4-6. Figure 5 The difference is that the second general calling interface can make outbound calling calls based on outbound call 1 and outbound call 2.
[0064] In other words, each outbound call identifier maps to a method of a generic API, rather than the entire generic API. Since the generic API is a unified whole, with multiple methods belonging to the same API, one generic API can correspond to multiple outbound call identifiers. This way, all service layers that need to access external data initiate calls through this same API, achieving a unified interface that can be reused by different services and with different data.
[0065] In other words, the second general-purpose invocation interface does not need to be associated with the outbound call identifier. It directly determines the target end through the outbound call identifier corresponding to the service code, and invokes the second Hypertext Transfer Protocol client to send the Extended Markup Language (EML) message and the target service code corresponding to the EML message to the target end. At this time, the second general-purpose invocation interface is decoupled from the outbound call identifier, and the outbound call identifier is associated with the service code.
[0066] Subsequently, the target end can dynamically call the corresponding interface through XML messages and service codes and return response information, which is a response XML message.
[0067] It is understood that, in some embodiments, the response information is obtained by the target end through a dynamic addressing method by calling an information interface based on the Extended Markup Language (EML) message and the corresponding target service code, to retrieve the information required by the data caller. The information interface is an internal interface within the target end that processes the EML message and the corresponding target service code to obtain the response information.
[0068] Specifically, the target receives an HTTP request from an HTTP client. The HTTP request includes an XML message and a target service code. Based on the target service code, the target determines the method of the internal business class that handles the HTTP request, i.e., the information interface. The information interface performs data querying on the extended markup language message to obtain the response information.
[0069] This dynamic addressing method is essentially a gateway pattern, providing a unified, flexible, powerful, and easy-to-maintain access layer for external systems. All HTTP requests pass through this access layer for distribution. There's no need to configure independent load balancing, firewall policies, and domain names for each new information interface. Only this one entry point needs to be maintained, reducing operational complexity and costs. Furthermore, the target's own backend services can be split, merged, upgraded, or rewritten at any time without the HTTP client's awareness.
[0070] In some embodiments, before executing S203, the HTTP client may receive a response XML message sent by the target end and obtain a data converter through the target extended markup language annotation configuration information. In other words, by calling the data converter in the outbound call component, the response information is transformed according to the target extended markup language annotation configuration information to obtain the target entity class. The target extended markup language annotation configuration information is in tabular form.
[0071] Understandably, the HTTP client is invoked by the service layer through a generic API call, and the target end returns the response information to the HTTP client, which is equivalent to returning the response information to the service layer. Since this response information is in XML format, the service layer also needs to perform data conversion on the response information to obtain data in entity class form that the data caller can recognize.
[0072] Since the data converter uses a JAXB encoder to convert entity classes into XML messages, a JAXB decoder can be used to convert response XML messages back into entity classes. Decoding via a JAXB decoder eliminates the need for users to deal with the tedious, error-prone, and low-level XML text parsing work, significantly improving development efficiency, code quality, and system maintainability. Furthermore, the tabular format of the target XML annotation configuration information provides a structured view, making the mapping relationships clear at a glance. This allows users to quickly see which fields correspond to which elements or attributes in the XML, avoiding repeatedly flipping through annotations in the code. Tables can serve as a consensus during the design phase, ensuring everyone follows the same naming and structural conventions, reducing differences caused by personal habits.
[0073] In some embodiments, in S203, the target service layer may encapsulate the target entity class to obtain the encapsulation result; and send the encapsulation result to the data caller.
[0074] This is because the data format returned by the target may not fully meet the internal business needs of the data caller. By encapsulating the data, we can obtain data that meets the internal business needs of the data caller.
[0075] Based on the data retrieval method provided in the above embodiments, this application also provides specific implementations of the data retrieval device. Please refer to the following embodiments.
[0076] like Figure 7 As shown, the data retrieval device 700 provided in this application embodiment includes the following modules: The data call request acquisition module 701 is used to acquire data call requests forwarded by the routing layer of the server. The data call request includes an information entity class and a target service code. The data call request is forwarded to the target service layer of the server by the routing layer after determining the target service layer corresponding to the target service code among several service layers based on the target service code and a pre-set first correspondence between service layers and service codes. The outbound call module 702 is used to receive response information returned by the target end by calling the outbound call component based on the target service code. The target end is a data storage provider that stores the data requested by the data caller. The outbound call component includes a data converter and a general call interface. The data converter is used to convert the information entity class into an extended markup language message. The general call interface is used to send the extended markup language message to the target end based on the outbound call identifier of the configuration information required for the target service layer outbound call obtained from the target service code. The response information sending module 703 is used to send the response information to the data caller.
[0077] The data retrieval device 700 described above is explained in detail below: In some embodiments, the outbound call module 702 may further include: The outbound call identifier determination module is used to determine the outbound call identifier of the configuration information required for the outbound call of the target service layer based on the target service code; The first data conversion module is used to convert the information entity class into an Extended Markup Language message by calling the data converter in the outbound call component according to the outbound call identifier. An extended markup language message sending module is used to send the extended markup language message to the target end by calling the general calling interface in the outbound call component; The response information receiving module is used to receive the response information returned by the target terminal.
[0078] In some embodiments, the first data conversion module may further include: The configuration information acquisition module is used to acquire target extended markup language annotation configuration information based on the outbound call identifier and the second correspondence between the identifier and the configuration information stored in advance. The configuration information includes the conversion relationship between the entity class called by each data call request and the extended markup language. The data conversion submodule is used to convert the data of the information entity class according to the target extended markup language annotation configuration information by calling the data converter in the outbound call component, so as to obtain the extended markup language message.
[0079] In some embodiments, the Extended Markup Language (EML) message sending module may further include: The first general call interface determination module is used to determine the first general call interface based on the outbound call identifier and the third correspondence between the pre-stored identifier and the general call interface. The first Extended Markup Language (EML) message sending submodule is used to call the first Hypertext Transfer Protocol (HTP) client through the first general call interface, so that the first HTP client calls the outbound call interface corresponding to the first general call interface to send the EML message and the target service code corresponding to the EML message to the target end.
[0080] In some embodiments, the Extended Markup Language (EML) message sending module may further include: The second Extended Markup Language (EML) message sending submodule is used to call the second Hypertext Transfer Protocol (HTP) client through the second general call interface, so that the second HTP client calls the outbound call interface corresponding to the outbound call identifier and sends the EML message and the target service code corresponding to the EML message to the target end.
[0081] In some embodiments, the response information includes an Extended Markup Language (EML) response message. The response information is obtained by the target end from the information interface through a dynamic addressing method based on the EML message and the target service code corresponding to the EML message, to obtain the information required by the data caller.
[0082] In some embodiments, the data retrieval device may further include: The second data conversion module is used to convert the response information according to the target extended markup language annotation configuration information by calling the data converter in the outbound call component before sending the response information to the data caller, so as to obtain the target entity class. The target extended markup language annotation configuration information is in tabular form.
[0083] In some embodiments, the response information sending module 703 can also be used to encapsulate the target entity class to obtain an encapsulation result; and send the encapsulation result to the data caller.
[0084] The data retrieval device in this embodiment receives a data retrieval request from a data retrieval party. The data retrieval request includes an information entity class and a target service code. Based on the target service code, it invokes an outbound call component to receive response information returned by the target end. The target end is a data storage provider storing the data requested by the data retrieval party. The outbound call component includes a data converter that converts the information entity class into an Extended Markup Language (EML) message and an outbound call identifier for the target service layer required for the outbound call, obtained based on the target service code. The EML message is sent to the target end, and the response information is sent to the general call interface of the data retrieval party. By encapsulating a unified outbound call component, the outbound call can be reused, eliminating the need for repeated development based on specific data, simplifying the development process, and reducing code redundancy. Since the message structures of requests and responses differ for each different data, a data converter is used to provide a standard, reusable message conversion mechanism. There is no need to manually maintain the relationships between each XML and entity class, reducing the need for manual message rewriting, thereby reducing a large amount of redundant code and development processes.
[0085] This application also provides a data retrieval system, which includes a routing component and a target service component, wherein: The routing component is used to receive a data call request sent by a data caller. The data call request includes an information entity class and a target service code. Based on the target service code and a pre-set first correspondence between service components and service codes, the component corresponding to the target service code is determined, and the data call request is sent to the target service component. The target service component is used to receive response information returned by the target end by calling the outbound call component based on the target service code, and send the response information to the data caller. The target end is a data storage provider that stores the data requested by the data caller. The outbound call component includes a data converter and a general call interface. The data converter is used to convert the information entity class into an extended markup language message. The general call interface is used to send the extended markup language message to the target end based on the outbound call identifier of the configuration information required for the outbound call of the target service component obtained by the target service code.
[0086] Based on the data retrieval method provided in the above embodiments, this application also provides specific implementation methods for electronic devices. Figure 8 A schematic diagram of an electronic device 800 provided in an embodiment of this application is shown.
[0087] Electronic device 800 may include processor 810 and memory 820 storing computer program instructions.
[0088] Specifically, the processor 810 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0089] Memory 820 may include mass storage for data or instructions. For example, and not limitingly, memory 820 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 820 may include removable or non-removable (or fixed) media. Where appropriate, memory 820 may be internal or external to electronic device 800. In a particular embodiment, memory 820 is a non-volatile solid-state memory.
[0090] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to the first aspect of this application.
[0091] The processor 810 implements any of the data retrieval methods in the above embodiments by reading and executing computer program instructions stored in the memory 820.
[0092] In one example, the electronic device 800 may also include a communication interface 830 and a bus 840. For example, Figure 8 As shown, the processor 810, memory 820, and communication interface 830 are connected through bus 840 and complete communication with each other.
[0093] The communication interface 830 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0094] Bus 840 includes hardware, software, or both, that couples components of an electronic device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 840 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0095] For example, the electronic device 800 can be a mobile phone, tablet computer, laptop computer, handheld computer, in-vehicle electronic device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc.
[0096] The electronic device can execute the data retrieval method in the embodiments of this application, thereby achieving the combination Figures 2 to 7 The data retrieval methods and apparatus described herein, and the beneficial effects of the corresponding method embodiments, will not be elaborated further here.
[0097] Furthermore, in conjunction with the data retrieval methods in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. This computer-readable storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the data retrieval methods in the above embodiments.
[0098] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0099] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0100] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0101] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0102] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A data calling method, characterized by, The method is applied to a server, and the method comprises: Obtaining a data call request forwarded by a routing layer of the server, wherein the data call request comprises an information entity class and a target service code; wherein the data call request is forwarded to a target service layer of the server after the routing layer determines the target service layer corresponding to the target service code in a plurality of service layers according to the target service code and a first correspondence relationship between the service layers and the service codes which is set in advance; Based on the target service code, a calling component is called to receive response information returned by a target end, wherein the target end is a data storage party storing data requested to be called by a data calling party, wherein the calling component comprises a data converter and a general calling interface, the data converter is used to convert the information entity class into an extensible markup language message, and the general calling interface is used to send the extensible markup language message to the target end based on a calling identifier of configuration information required by the target service layer obtained based on the target service code; The response information is sent to the data calling party.
2. The method of claim 1, wherein, Based on the target service code, a calling component is called to receive response information returned by a target end, and the method comprises the following steps: Based on the target service code, a calling identifier of configuration information required by the target service layer is determined; According to the calling identifier, the data converter in the calling component is called to convert the information entity class into an extensible markup language message; The general calling interface in the calling component is called to send the extensible markup language message to the target end; The response information returned by the target end is received.
3. The method of claim 2, wherein, According to the calling identifier, the data converter in the calling component is called to convert the information entity class into an extensible markup language message, and the method comprises the following steps: According to the calling identifier and a second correspondence relationship between the identifier and configuration information stored in advance, target extensible markup language annotation configuration information is obtained, wherein the configuration information comprises a conversion relationship between an entity class called by each data call request and an extensible markup language; The data converter in the calling component is called to perform data conversion on the information entity class according to the target extensible markup language annotation configuration information, so as to obtain an extensible markup language message.
4. The method of claim 2, wherein, The general calling interface in the calling component is called to send the extensible markup language message to the target end, and the method comprises the following steps: According to the calling identifier and a third correspondence relationship between the identifier and the general calling interface stored in advance, a first general calling interface is determined; The first hypertext transfer protocol client is called through the first general calling interface, so that the first hypertext transfer protocol client calls a calling interface corresponding to the first general calling interface, and the extensible markup language message and the target service code corresponding to the extensible markup language message are sent to the target end.
5. The method of claim 2, wherein, The general calling interface in the calling component is called to send the extensible markup language message to the target end, and the method comprises the following steps: The second universal calling interface is used to call the second hypertext transfer protocol client, so that the second hypertext transfer protocol client calls an outbound interface corresponding to the outbound identifier, and sends the extensible markup language message and the target service code corresponding to the extensible markup language message to a target end.
6. The method of claim 1, wherein, The response information includes an extensible markup language response message, and the response information is obtained by the target end based on the extensible markup language message and the target service code corresponding to the extensible markup language message, by calling an information interface through a dynamic addressing method.
7. The method of claim 3, wherein, Before the response information is sent to the data calling party, the method further comprises: The data converter in the outbound component is called to convert the response information according to the target extensible markup language annotation configuration information to obtain a target entity class, and the target extensible markup language annotation configuration information is in a table form.
8. The method of claim 7, wherein, The response information is sent to the data calling party, and specifically comprises: The target entity class is encapsulated to obtain an encapsulation result. The encapsulation result is sent to the data calling party.
9. A data call system, characterized by, The system comprises a routing component and a target service component, wherein: The routing component is configured to receive a data calling request sent by a data calling party, the data calling request comprising an information entity class and a target service code, determine a service component corresponding to the target service code according to a first correspondence relationship between the target service code and service components and service codes that are set in advance, and send the data calling request to the target service component. The target service component is configured to call an outbound component based on the target service code, receive response information returned by a target end, and send the response information to the data calling party, the target end being a data storage party that stores data requested by the data calling party, wherein the outbound component comprises a data converter and a universal calling interface, the data converter is configured to convert the information entity class into an extensible markup language message, and the universal calling interface is configured to send the extensible markup language message to the target end based on an outbound identifier of configuration information required for outbound of the target service component obtained based on the target service code.
10. A data calling apparatus, characterized by comprising: The device comprises: A data calling request obtaining module is configured to obtain a data calling request forwarded by a routing layer of a server, the data calling request comprising an information entity class and a target service code, wherein the data calling request is forwarded to a target service layer of the server after the routing layer determines the target service layer corresponding to the target service code in a plurality of service layers based on a first correspondence relationship between the target service code and service layers and service codes that are set in advance. The external call calling module is configured to call an external call component based on the target service code to receive response information returned by a target end, the target end being a data storage party that stores data requested by a data calling party, wherein the external call component comprises a data converter and a general call interface, the data converter is configured to convert the information entity class into an extensible markup language message, and the general call interface is configured to send the extensible markup language message to the target end based on an external call identifier of configuration information required by the target service layer external call obtained based on the target service code. The response information sending module is configured to send the response information to the data calling party.
11. An electronic device, comprising: The electronic device comprises a processor and a memory storing computer program instructions. The processor executes the computer program instructions to implement the data calling method in any one of claims 1-8.
12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions, and the computer program instructions are executed by the processor to implement the data calling method in any one of claims 1-8.
13. A computer program product, characterised in that, The instructions in the computer program product are executed by the processor of the electronic device, so that the electronic device executes the data calling method in any one of claims 1-8.