CN113676521A - Service request response method and device and electronic equipment - Google Patents

Service request response method and device and electronic equipment Download PDF

Info

Publication number
CN113676521A
CN113676521A CN202110864008.2A CN202110864008A CN113676521A CN 113676521 A CN113676521 A CN 113676521A CN 202110864008 A CN202110864008 A CN 202110864008A CN 113676521 A CN113676521 A CN 113676521A
Authority
CN
China
Prior art keywords
service
data
response
service request
attribute information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110864008.2A
Other languages
Chinese (zh)
Inventor
曹彬
郭子淳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202110864008.2A priority Critical patent/CN113676521A/en
Publication of CN113676521A publication Critical patent/CN113676521A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The disclosure provides a service request response method and device and electronic equipment, and relates to the technical field of computers, in particular to the field of cloud platforms. The method applicable to the server comprises the following steps: receiving a service request, and acquiring attribute information and request content of the service request; acquiring service data requested by the service request according to the request content; and generating a response packet according to the service data and the attribute information, and sending the response packet to a corresponding client, wherein the response packet comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data. According to the method and the system, the response logic between the server and the client is unified, so that the server can pack different service data corresponding to different service interfaces based on the same format, the data interaction process between the server and the client is simplified, the development time between the client and the server is saved, and the development resources are effectively saved.

Description

Service request response method and device and electronic equipment
Technical Field
The present disclosure relates to the field of computer technology, and more particularly, to the field of cloud computing platforms.
Background
In the implementation, various data request interfaces exist between the client and the server, and the client realizes data interaction with the server through the data request interfaces, so that different applications of the client are realized. In the related art, different data request interfaces have different response formats, so that the client and the server need to separately develop response analysis logic for the different data request interfaces based on the different response formats, and a large development cost needs to be consumed.
Disclosure of Invention
The disclosure provides a service request response method and device and electronic equipment.
According to a first aspect of the present disclosure, there is provided a method for responding to a service request, which is applicable to a server, the method including: receiving a service request, and acquiring attribute information and request content of the service request; acquiring the service data requested by the service request according to the request content; and generating a response packet according to the service data and the attribute information, and sending the response packet to a corresponding client, wherein the response packet comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data.
According to a second aspect of the present disclosure, there is provided a method for responding to a service request, which is applied to a client, the method including: sending a service request to a server, wherein the service request comprises attribute information and request content; receiving a response packet of the service request sent by the server, wherein the response message comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data; and unpacking the response packet to acquire the service data requested by the service request from the data body.
According to a third aspect of the present disclosure, there is provided a service request responding apparatus, adapted to a server, the apparatus including: the receiving module is used for receiving a service request and acquiring attribute information and request content of the service request; the acquisition module is used for acquiring the service data requested by the service request according to the request content; and the generating module is used for generating a response packet according to the service data and the attribute information and sending the response packet to a corresponding client, wherein the response packet comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data.
According to a fourth aspect of the present disclosure, there is provided a device for responding to a service request, which is suitable for a client, the device including: the system comprises a sending module, a receiving module and a sending module, wherein the sending module is used for sending a service request to a server, and the service request comprises attribute information and request content; a receiving module, configured to receive a response packet of the service request sent by the server, where the response message includes a message header and a data body, where the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data; and the unpacking module is used for unpacking the response packet to acquire the service data requested by the service request from the data body.
According to a fifth aspect of the present disclosure, there is provided an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of responding to a service request according to any of the first and second aspects.
According to a sixth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method for responding to a service request of any one of the first and second aspects.
According to a seventh aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method of responding to a service request of any of the first and second aspects described above.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a schematic flow chart of a service request response method according to an embodiment of the present disclosure;
fig. 2 is a schematic flow chart of a service request response method according to another embodiment of the present disclosure;
fig. 3 is a schematic flow chart of a service request response method according to another embodiment of the present disclosure;
fig. 4 is a schematic flow chart of a service request response method according to another embodiment of the present disclosure;
fig. 5 is a schematic flow chart of a service request response method according to another embodiment of the present disclosure;
fig. 6 is a flowchart illustrating a method for responding to a service request according to another embodiment of the disclosure;
fig. 7 is a flowchart illustrating a method for responding to a service request according to another embodiment of the disclosure;
fig. 8 is a schematic structural diagram of a service request response device according to an embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of a service request response device according to another embodiment of the present disclosure;
fig. 10 is a schematic structural diagram of a service request response device according to another embodiment of the present disclosure;
fig. 11 is a schematic structural diagram of a service request response device according to another embodiment of the present disclosure;
fig. 12 is a schematic block diagram of an electronic device of an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Computer Technology may be divided into several aspects, Computer system Technology, Computer machine component Technology, Computer component Technology, and Computer assembly Technology. The computer technology comprises the following steps: the basic principle of the operation method, the design of an arithmetic unit, an instruction system, the design of a Central Processing Unit (CPU), the pipeline principle, the application of the basic principle in the CPU design, a storage system, a bus and input and output. The method refers to technical methods and technical means applied in the field of computers, or refers to hardware technology, software technology and application technology thereof.
A Cloud Computing Platform (also called Cloud Platform) refers to a service based on hardware resources and software resources, and provides Computing, network, and storage capabilities. Cloud computing platforms can be divided into 3 classes: the cloud computing platform comprises a storage type cloud platform taking data storage as a main part, a computing type cloud platform taking data processing as a main part and a comprehensive cloud computing platform taking computing and data storage processing into consideration.
Fig. 1 is a schematic flowchart of a method for responding to a service request according to an embodiment of the present disclosure, where the method is applied to a server, and as shown in fig. 1, the method includes:
s101, receiving a service request, and acquiring attribute information and request content of the service request.
The client can realize the related functions set by the client through information interaction with the server, wherein different functions need to be realized through corresponding service data, and therefore, the client needs to send different service requests, such as information query and the like, to the server based on different services.
In the implementation, at least one service interface exists between the server and the client, and information interaction between the server and the client can be realized based on the service interface.
In order to realize information interaction through the service interface, response logic exists between the server and the client, the response format of the service interface can be limited based on the response logic, and the server can package data needing interaction according to the set format and transmit the data through the service interface, so that the aim of information interaction is fulfilled.
In the embodiment of the present disclosure, the response formats of all the service interfaces may be defined based on a uniform response logic, so that different service interfaces may adopt the same response format.
Further, the client sends the service request to the server through the service interface based on the uniform response logic. After receiving the service requirement, the server can extract the required content from the service requirement, including the attribute information and the request content.
The attribute information may include an identifier of the service type, an identifier of the request type, a timestamp, and other related information, and the request content is related information of detailed service data required by the service request.
And S102, acquiring the service data requested by the service request according to the request content.
The server can call the service data required by the client from the service data storage position of the server based on the acquired service request.
Alternatively, the acquisition of the service data may be implemented based on the requested content. And setting keywords corresponding to different functions according to the functions of the client, and setting a corresponding mapping relation between the keywords and the corresponding service data. After obtaining the keywords carried in the service request, the server may query the set mapping relationship, and further obtain service data corresponding to the service request.
And S103, generating a response packet according to the service data and the attribute information, and sending the response packet to the corresponding client, wherein the response packet comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data.
In the embodiment of the present disclosure, after the server obtains the service data corresponding to the service request, the service data and the related attribute information need to be packaged, and then a corresponding response packet is generated.
Further, data packaging can be performed based on a response format defined by the uniform response logic to generate a corresponding response packet, and the response packet is sent to the client.
Alternatively, the service data and the attribute information may be packaged based on a Client/Server (C/S) protocol, where the response packet includes two parts, namely a data body and a message header.
The message header in the response packet may be generated based on the server response and the related attribute information of the acquired service data, and it may be understood that the message header has a set format, and a unified message header may be generated according to the set format based on the content included in the attribute information.
Further, based on the related content of the service data acquired by the server, the data body in the response packet may be generated, and it may be understood that the data body has a set format, and a unified data body may be generated based on the service data and the attribute information.
It should be noted that the unified message header and the unified data body are only unified in format, and specific values are different in different service types.
Further, the server transmits a response packet corresponding to the packaged service request to the client through a set service interface.
According to the method for responding the service request, after the server acquires the service request sent by the client, the attribute information and the request content in the service request are extracted, corresponding service data are acquired according to the request content, the related attribute information of the server responding to the service request and the acquired service data are packaged based on the set response format, a message header is generated based on the attribute information, a data body is generated based on the service content, and then a corresponding response packet is generated and transmitted to the client. According to the method and the system, the response logic between the server and the client is unified, the response format of the server for data packaging is limited by the unified response logic, so that the server packages different service data corresponding to different service interfaces based on the same format, and generates the response packet with the unified response format, and therefore the data interaction process between the server and the client is simplified, the development time of the client and the server is saved, and the development resources are effectively saved.
In the foregoing embodiment, regarding generation of the response packet, as can be further understood with reference to fig. 2, fig. 2 is a schematic flowchart of a response method for a service request according to another embodiment of the present disclosure, where the method is applied to a server, and as shown in fig. 2, the method includes:
s201, according to the attribute information, assigning a first general field including a first set sequence in the message header to generate the message header.
In the embodiment of the disclosure, data interaction is realized between the server and the client through the response packet, wherein the server packages the service data and the attribute information corresponding to the service request to generate the response packet, and the client can extract data from the response packet.
The response packet has a message header generated based on the attribute information, and the client can acquire the response state of the server through the field content of the message header. Alternatively, a plurality of fixed fields may be set in the message header, and the relevant status of the server response is obtained by reading the contents of the fixed fields. Further, this portion of the fixed field used to embody the relevant state of the server response may be determined as the first general field in the message header.
In an implementation, an arrangement order is set for a first general field in a message header in a response format, and each field in the first general field is sequentially arranged based on the set arrangement order, so that the arrangement order may be determined as the first set order of the first general field.
The first general field in the message header defines the type of information that can be transmitted by the response packet, and further, the first general field can be assigned, and by reading the content assigned to the first general field, the client can obtain the detailed content of the relevant response state of the server.
Further, the configuration parameters of the first general field are extracted from the attribute information.
In the embodiment of the present disclosure, the configuration parameter of the first general field may be obtained from the attribute information, the server may extract the configuration parameter from the attribute information, and the relevant state of the server response may be obtained by reading the information corresponding to the configuration parameter. Therefore, the configuration parameters corresponding to the first general field can be obtained from all the configuration parameters of the attribute information, and assignment of the first general field is further realized.
Optionally, a keyword corresponding to each field in the first general field may be extracted, and the keyword is extracted from the configuration parameters included in the attribute information, so as to obtain the configuration parameters corresponding to the first general field.
And further, assigning the first general field according to the first setting sequence and based on the configuration parameters of the first general field, and further generating a message header in the response packet.
For example, if the first general field of the header in the response packet is set to include a status field, an msg field, a logic field, and a timestamp field, and the first general field is assigned based on the attribute information, a corresponding header may be generated as follows:
"status":0,
"msg":"",
"logid":"1760505286",
"timestamp":"1553848923000",
wherein, the status field, the msg field, the logic field and the timestamp field are arranged based on a first set order. The status field, msg field, logic field, and timestamp field, and the corresponding contents of the fields, form the header of the response packet in this example.
Further, in the message header, the response state of the server may be determined by the value of the status field, and as can be seen from the example, if the value of the status field in the current response packet is 0, it may be determined that the response of the current server to the service request of the client is successful.
The msg field may be a word, and the content of the field may be understood as that, for a supplementary description of the response state, if the value of the status field is not 0, the msg field may supplement a different value of the status field, for example, when the status field is 1, the msg field may not exist for the user, and when the status field is 2, the msg field may be a server state exception, and the like.
The value of the logic field is the identification information of the service request, and the positioning of the related data can be realized based on the identification information.
the value content of the timestamp field is the time corresponding to the receiving and responding of the server to the service request.
The response state of the service request can be obtained, and the target general field in the first general field is assigned according to the response state.
In implementation, the server packages the response state of the service request into a response packet, wherein a field in the message header for embodying the response state of the server may be determined as a target general field, and the target general field is assigned based on the configuration parameter of the field in the attribute information. The client can obtain the response state of the server to the service request based on the assignment content of the field in the response packet.
Still taking the above example as an example, wherein the status field is the target general field, and is assigned with 0 based on the attribute information, as follows:
"status":0,
"msg":"",
optionally, the configuration parameter in the attribute information that the response state to the server is normal may be set to 0, and based on the configuration parameter corresponding to the status field in the attribute information, the field may be assigned with 0, and the client may determine that the response of the current server to the service request of the client is successful based on the assignment.
For another example, the status field is assigned a value of 1 based on the attribute information, as follows:
"status":1,
"msg": user does not exist ",
optionally, the configuration parameter for the server response state exception in the attribute information may be set to be non-0, and different parameter values may refer to different exception states. For example, the configuration parameter of the abnormal state that the user does not have a corresponding value may be set to 1, and when the server finds the abnormal state of the type during data acquisition, the client may assign a value of 1 to a status field in the attribute information based on the configuration parameter corresponding to the field, and may determine that the current server response state is abnormal based on the assignment.
Further, in order to obtain the specific situation of the exception in more detail, a supplementary explanation may be given for the exception situation represented by the status field. Alternatively, this may be achieved by the msg field. The msg field can be supplementary text content, when the status field is assigned as 1, the configuration parameter corresponding to the msg field in the attribute information is the supplementary description for 1, and the msg field is assigned as not existing for the user based on the configuration parameter of the field in the attribute information.
S202, according to the service data and the attribute information, filling a second general field and an array which comprise a second set sequence in the data body, and generating the data body.
In the embodiment of the present disclosure, the server may package the service data corresponding to the service request and the related attribute information, and generate the data body in the response packet.
The data body can have a plurality of fixed fields, the type of information that can be transmitted by the data body in the response packet can be defined by the set fixed fields, and the part of the fixed fields is determined as a second general field of the data body.
Further, the second general fields have a set arrangement order, and the second general fields are sequentially arranged based on the set arrangement order. Wherein the set arrangement order may be determined as the second set order.
Wherein, the service type identifier of the service request is extracted from the attribute information.
In the implementation, the server may extract the service type identifier from the attribute information, the different service type identifiers belong to different service interfaces, and the server may determine the service interface where the response packet is returned to the client based on the different service type identifiers.
Optionally, a connection relationship may be established between each service interface and the service type identifier corresponding thereto, and after the server extracts the service type identifier from the attribute information, the server may determine that the response packet returns to the corresponding service interface based on the established connection relationship.
Setting that when the service type identifier is name, the corresponding service interface is interface a, and when the data body in the response packet is as follows:
Figure BDA0003186865950000081
the data field, the business field, the actions field, and the content corresponding to each field are the data body of the response packet in this example.
Further, in the data body, the data field may be used as a separation field between the message header and the data body, and the content of the data field is the detailed content of the data body packaged by the server based on the service request sent by the client.
The business field is identification information of the business request, and based on the content of the field, the client can determine a business layer for processing the business data in the response packet. The content of actions field is the detailed data of the next layer, after the identification information corresponding to the service data is determined, the specific service data to be processed by the corresponding service layer can be obtained through the content of actions field, and the relevant functions of the client side are realized based on the content in actions field.
And if the business type identifier corresponding to the data body is name, it can be determined that the response packet corresponding to the data body can be returned to the client from the interface a.
And further, according to a second set sequence, assigning a value to the second general field based on the service type identifier, and writing the service data into the array to generate a data body.
In the embodiment of the present disclosure, the fields in the second general field are arranged based on a second setting order, and after the server extracts the parameters of the second general field from the attribute information, the server may assign values to the second general field in sequence based on the second setting order.
Further, the service data corresponding to the service request may be written in the data volume in the form of an array, and the client acquires the detailed service data corresponding to the service request based on the portion of the array content in the data volume.
For example, if service data corresponding to the service request acquired by the server is XXX and the service type identifier is city, the XXX is assigned to the second general field based on the second set order, and then written into an array corresponding to the service data, so that a data body as shown below can be generated:
Figure BDA0003186865950000091
wherein, the bussiness field and the actions field are arranged based on the second setting sequence.
Optionally, the service type identifier may be obtained by assigning a bussiness field, and as can be seen from the above example, the server obtains the service type city corresponding to the service request from the attribute information, and assigns the service type city to the bussiness field.
Optionally, the detailed service data corresponding to the service request may be written into an array under the actions field, as shown in the above example, if the server obtains the corresponding service data as XXX based on the service request, the data is written into the array.
And further, arranging the assigned second general fields and the assigned arrays based on a second set sequence, and further generating corresponding data bodies.
S203, packaging the message header and the data body to generate a response packet.
In the embodiment of the present disclosure, the response packet includes a message header and a data body, and after the message header and the data body are respectively generated, the message header and the data body may be arranged based on a response format, so as to generate a response packet corresponding to the service request.
On the basis of the above example, the response packet generated based on the message header and the data body may be as follows:
Figure BDA0003186865950000101
the status field indicates that the server response state is normal, the msg field is assigned to be null, the logic field is assigned to be positioning characters corresponding to the service request, the timestamp field is assigned to be a timestamp corresponding to the server response service request, the data field is a data body part in the response packet, the service request sent by the client is an urban service request through assignment of the business field, corresponding service data acquired by the server is XXX, and further, the response packet corresponding to the service request is generated and transmitted to the client through a corresponding service interface.
It should be noted that the client may transmit the service request to the server through any one of the service interfaces based on the service requests of different types, and the server may receive the service request sent by the client through any one of the service interfaces and generate a corresponding response packet based on the received service request. It will be appreciated that the format of the response packets for service interface a and service interface B is the same as that of the code portions in the above embodiments, except that the same fields have different values. For example, the timestamp field is assigned as a timestamp corresponding to the server response service request, interface a is 1553848923000, and interface B is 1553848923000.
The disclosure provides a response method of a service request, which assigns values to a first general field in a message header according to a first set sequence based on a uniformly defined response format and according to attribute information to generate a corresponding message header. And assigning values to the second general fields in the data body according to the service data and the attribute information corresponding to the service request and generating the corresponding data body. And further, generating a response packet corresponding to the service request based on the message header and the data body. According to the method and the system, the client and the server can uniformly respond to the analysis logic, so that the server can generate the response packet corresponding to the service request based on the uniform response format, the client can realize unpacking of the response packet based on the uniform response logic, the data interaction process between the server and the client is simplified, the development time of the client and the server is saved, and the development resources are effectively saved.
In the implementation, response logic is unified between the server and the client, the server can generate a response packet based on a unified response format, and each service interface uses the same response logic in a scenario where a plurality of service interfaces exist between the server and the client. It can be understood that, for each service interface, the generation of the response packet corresponding to the different service interfaces is realized by performing different assignments on the same field. In response packets corresponding to different service interfaces, the fields used and the arrangement structure between the fields are the same.
Correspondingly, in order to implement the above method for responding to a service request applied to a server, the present disclosure also provides a method for responding to a service request applied to a client, which can be further understood with reference to fig. 3, where fig. 3 is a schematic flow diagram of a method for responding to a service request according to another embodiment of the present disclosure, and as shown in fig. 3, the method includes:
s301, a service request is sent to the server, wherein the service request comprises attribute information and request content.
In the implementation, the related functions of the client need to be implemented depending on the related service data in the server, so that the client can write the attribute information and the request content into the service request, the server extracts the attribute information and the request content in the service request, generates a corresponding response packet, and then returns the service data required by the client.
Alternatively, the client may generate a corresponding service request based on the set response logic between the server and the client, and send the service request to the server through any one of the service interfaces.
S302, receiving a response packet of a service request sent by a server, wherein the response message comprises a message header and a data body, the message header is generated according to attribute information, and the data body is generated according to the attribute information and service data.
In the embodiment of the present disclosure, the server may generate a corresponding response packet based on the service request sent by the client, and send the response packet to the client through the corresponding service interface.
Further, the client may accept the response packet returned by the server. In the implementation, a set response logic exists between the server and the client, the server packages the service data and the attribute information returned by the server based on the response logic to generate a response packet, and the client can read the data in the response packet based on the set response logic and acquire the message header and the data body in the response packet.
Through reading the assignment of the first general field in the message header, relevant attribute information of server response in the service data acquisition process can be determined, such as response success, response exception and specific reasons of the exception.
Through reading the assignment of the second general field in the data body, the service type identifier and the detailed service data returned by the service request can be obtained.
As can be seen from the above example, the message header in the response packet may be as follows:
"status":0,
"msg":"",
"logid":"1760505286",
"timestamp":"1553848923000",
the client can obtain the relevant attribute information of the server for the service request response sent by the client by reading the assignment of the first general field.
The data volume in the response packet may be as follows:
Figure BDA0003186865950000121
the client can obtain the service type representation and the detailed service data returned by the server to the service request sent by the client by reading the assignment of the second general field.
S303, unpacking the response packet to obtain the service data requested by the service request from the data body.
In the embodiment of the present disclosure, after receiving the response packet, the client may perform unpacking processing on the response packet based on the response logic between the server and the client, and further read the message header and the data body therein.
Still as shown in the above example, the service type returned by the server is "name", and the detailed service data corresponding to the service request is obtained from the content in the actions field, as can be seen from the above example, the service data obtained by the server this time is%%, and the client can obtain the specific service data%%, based on the array content in the field.
The method for responding the service request is based on the set response logic, the client generates the service request sending server based on the attribute information and the request content, receives the response packet returned by the server, unpacks the response packet, reads the message header and the data body in the response packet, and further obtains the relevant attribute information and the specific service data of the server responding to the service request at this time. According to the method and the device, the response logic is unified for the client and the server, the response format is limited based on the unified response logic, so that the server can pack different service data corresponding to different service interfaces based on the same response format to generate a response packet with the unified response format, and the client can unpack the response packet based on the unified response logic, so that the data interaction process between the server and the client is simplified, the development time of the client and the server is saved, and the development resources are effectively saved.
As one possibility, regarding unpacking of the response packet, as can be further understood in conjunction with fig. 4, fig. 4 is a schematic flow chart of a response method of a service request according to another embodiment of the present disclosure, the method is applicable to a client, as shown in fig. 4, and the method includes:
s401, analyzing the message header and the data body from the response message.
In the embodiment of the present disclosure, a set response logic exists between the server and the client, and the server generates a response packet corresponding to the service request based on the set response logic, so that the client can unpack the response packet based on the response logic.
Alternatively, the response logic may be set based on the C/S protocol.
Further, after receiving the response packet, the client unpacks the response packet based on the set response logic and reads the message header and the data body in the response packet.
The message header is generated based on attribute information of a response of the server to the service request, and the data body is generated based on a service type identifier corresponding to the service request and detailed service data.
Further, the client may implement a function corresponding to the service request based on the obtained response packet.
S402, parameter values of the first general field are extracted from the message header in sequence.
In the embodiment of the disclosure, the client may read information transmitted in a message header in the response packet based on the first set order, so as to determine the relevant attribute information of the server for the service request response.
Wherein, the specific content of the related attribute information can be determined from the parameter value assigned by the first general field in the message header.
For example, from the value assigned to the status field, it can be determined whether the server responds to the service request successfully. Based on the above example, it can be known that when the parameter value of the status field read by the client is 1, it may be determined that the response to the service request sent by the client is abnormal this time, and the specific condition of the abnormality is determined by the parameter value of the msg field.
In implementation, the first general fields are arranged based on a first setting sequence, so that the client can sequentially read the parameter values of the fields based on the first setting sequence, and further obtain the parameter value corresponding to each field.
And S403, in response to the parameter value of the first general field indicating that the service request response is successful, extracting service data from the data body.
In the embodiment of the present disclosure, whether the response of the service request is successful may be determined by reading the parameter value of the first general field.
Based on the above example, it can be seen that when the parameter value of the status field in the first general field read by the client is 0, it can be determined that the server responds to the service request sent by the client successfully this time.
The client can determine that the server responds to the service request sent by the client successfully based on the reading of the parameter value in the first general field, and then can judge that the service data carried in the data body in the response packet returned by the current server to the client is the service data required by the service request of the client, and further can extract the service data in the data body.
And acquiring a configuration parameter value of a second general field in the data body to acquire the service type identifier of the service request.
In the embodiment of the present disclosure, a plurality of service layers exist in the client, and each service layer is set to process service data of different service types, so after the client acquires the response packet, it needs to determine the service layer that can process the service data in the response packet. Optionally, the identifier of the service type may be determined according to a parameter value of the second general field in the data body, and then a service layer used for processing the service data in the response packet returned by the server in the client is determined.
Still taking the above example as an example, it can be known from the parameter value of the status field that the response of the server to the service request sent by the client is successful, then the service data in the data body is further extracted, the service type corresponding to the service data returned by the server can be determined according to the parameter value of the business field, it can be known from the example that the service type identifier of the service data in the response packet returned by the server is name, then the service layer capable of processing the name service type in the client can be determined based on the parameter value, and the obtained detailed service data is sent to the hierarchy for further data processing.
Further, service data is extracted from an array in the data body, wherein the service type identifier is used for indicating a service interface to which the service data belongs.
In this embodiment of the disclosure, the client may extract the parameter values corresponding to the second general fields one by one from the data volume according to the second setting order.
As can be seen from the above example, after the service type corresponding to the parameter value of the business field is determined, the detailed service data corresponding to the service request may be extracted from the array of actions fields.
In the implementation, the client may transmit the service data to the corresponding service layer through the service interface to perform data processing, and therefore, the service interface corresponding to the service layer that can process the service data in the current response packet needs to be determined through the service type identifier.
S404, determining a target service interface corresponding to the response packet according to the service type identifier.
In the embodiment of the present disclosure, the service type identifiers corresponding to different service interfaces may be determined based on the attribute information of the service interfaces, and a connection relationship between the service type identifiers and the service interfaces may be established.
After the client reads the service type identifier in the data body, a preset connection relation is inquired based on the obtained related keywords in the service type identifier, and then a service interface to which the service type corresponding to the service data in the current response packet belongs is determined.
Further, the service interface corresponding to the response packet may be determined as the target service interface.
On the basis of the above example, if the interface corresponding to the service type identifier is the interface a, in the above example, the target service interface corresponding to the service data in the response packet is the service interface a, and the detailed service data extracted from the data body needs to be sent to the service layer corresponding to the service interface a for data processing.
S405, the service data is sent to the target service interface and processed by the service layer of the target service interface.
In the embodiment of the present disclosure, after the target service interface is determined based on the service type identifier, the service layer corresponding to the target service interface may be determined as the service layer for processing the service data in the response packet.
The service layer can further convert and process various array information carried by the service data, so that the client can realize related functions based on the service data.
According to the service request response method provided by the disclosure, the client reads the message header and the data body in the response packet returned by the server based on the set response logic, and further extracts the service data required by the service request. And determining relevant attribute information of the server based on the response of the service request based on the parameter values of the fields in the message header, determining a service layer for processing the service data based on the parameter values of the fields in the data body, and sending the extracted service data to the corresponding service layer for data processing. According to the method and the system, the client and the server can uniformly respond to the analytic logic, the client can realize unpacking of the response packet based on the uniform response logic, the data interaction process between the server and the client is simplified, the development time of the client and the server is saved, and the development resources are effectively saved.
As another possibility, regarding unpacking of a response packet, as can be further understood in conjunction with fig. 5, fig. 5 is a schematic flowchart of a response method for a service request according to another embodiment of the present disclosure, where the method is applicable to a client, as shown in fig. 5, and the method includes:
s501, analyzing a message header and a data body from the response message.
And S502, extracting the parameter values of the first general field in the message header in sequence.
Steps S501 to S502 may participate in the above related details, which are not described herein again.
S503, in response to the parameter value of the first general field indicating that the service request has not been successfully responded, discarding the response message.
In implementation, the client may determine whether the server responds to the service request successfully through the parameter value of the first general field in the message header. In response logic set between the server and the client, corresponding parameter values are set for response abnormal conditions, and different parameter values can be assigned to the first general field in the message header based on different abnormal conditions.
For example, part of the first general fields in the header of the message in the response packet are set as follows:
"status":1,
"msg": user does not exist ",
when the parameter value of the status field in the first general field is 1, it may be determined that the server response is abnormal, and it can be known by reading the parameter value of the msg field that the reason for the server response abnormality is that the user does not exist.
Further, the client may discard the response packet for which the response is unsuccessful, and perform presentation on the client based on a specific reason of the response exception.
According to the response method of the service request, whether the response of the server is abnormal or not can be judged by reading the parameter value of the first general field in the message header, the response packet which is not successfully responded is discarded, and the storage resource of the client is effectively saved.
Further, to better understand the establishment of a unified response logic between the server and the client, the following examples may be incorporated:
two service interfaces, namely an interface A and an interface B, exist between the server and the client, and the interface A and the interface B have respective corresponding interface logics before the unification of the response logics is carried out.
As shown in fig. 6(a), the client sends the service request to the server based on the response logics of the interface a and the interface B, after the server obtains the corresponding service data, the server packages the service request based on the response logics of the interface a and the interface B, generates corresponding response packets, and returns the response packets to the client through the interface a and the interface B, and the client unpacks the service request based on the response logics of the interface a and the interface B, and reads the fields and the corresponding parameter values.
In order to read the response packet generated by packaging based on the two different response formats, two sets of corresponding response logics need to be set between the server and the client, and development cost is increased.
Then, as shown in fig. 6(B), the interface a and the interface B may be set to a unified response logic, so that the server and the client may implement information interaction between the server and the client at different service interfaces based on the unified response logic.
The client sends the service request to the server based on the uniform response logic, the server packages the service request based on the uniform response logic after acquiring corresponding service data, generates corresponding response packets and returns the response packets to the client through the interface A and the interface B respectively, and the client unpacks the response packets returned by the interface A and the interface B respectively based on the uniform response logic and reads fields and corresponding parameter values in the response packets.
The server respectively generates message headers and data bodies in response packets of the interface A and the interface B based on a response format defined by a uniform response logic, and arranges the message headers and the data bodies based on a set sequence to further generate response packets corresponding to the service requests sent by the interface A and the interface B.
Further, for better understanding of the above embodiments, with reference to fig. 7, fig. 7 is a schematic flow chart of a service request response method according to another embodiment of the present disclosure, as shown in fig. 7:
the client respectively initiates service requests through a service interface A and a service interface B, the server respectively receives the service requests of the service interface A and the service interface B, respectively obtains service data corresponding to the service requests of the service interface A and the service interface B, respectively packages and generates response packets corresponding to the service requests of the service interface A and the service interface B based on attribute information and the service data according to a response format defined by a uniform response logic between the server and the client, and transmits the response packets back to the client through the service interface A and the service interface B.
And the client unpacks the response packets returned by the service interface A and the service interface B respectively based on the uniform response logic, and reads the message header and the data body in the response packets. The response state of the server is judged from the parameter value of the field in the message header. And if the response is determined to be successful, extracting the service data in the data body, determining a service layer for data processing based on the service type identifier obtained from the data body, and further sending the extracted detailed service data to the corresponding service layer for data processing. And if the response is determined to be unsuccessful, discarding the service data in the data body.
According to the method and the device, the response logic between the server and the client is unified, so that the server can generate the response packet corresponding to the service request based on the unified response format, and the client can realize unpacking of the response packet based on the unified response logic, so that the data interaction process between the server and the client is simplified, the development time of the client and the server is saved, and the development resources are effectively saved.
Corresponding to the service request response methods provided by the above several embodiments, an embodiment of the present disclosure further provides a service request response device, and since the service request response device provided by the embodiment of the present disclosure corresponds to the service request response methods provided by the above several embodiments, the implementation of the service request response method is also applicable to the service request response device provided by the embodiment of the present disclosure, and will not be described in detail in the following embodiments.
Fig. 8 is a schematic structural diagram of a service request response apparatus according to an embodiment of the present disclosure, where the apparatus is applied to a server, and as shown in fig. 8, the service request response apparatus 100 includes a receiving module 11, an obtaining module 12, and a generating module 13, where:
a receiving module 11, configured to receive a service request, and obtain attribute information and request content of the service request;
an obtaining module 12, configured to obtain service data requested by the service request according to the request content;
and the generating module 13 is configured to generate a response packet according to the service data and the attribute information, and send the response packet to the corresponding client, where the response packet includes a message header and a data body, where the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data.
Fig. 9 is a schematic structural diagram of a service request response apparatus according to an embodiment of the present disclosure, where the apparatus is applied to a server, and as shown in fig. 9, the service request response apparatus 200 includes a receiving module 21, an obtaining module 22, and a generating module 23, where:
the receiving module 21, the acquiring module 22, the generating module 23, the receiving module 11, the acquiring module 12, and the generating module 13 have the same configuration and function.
In the embodiment of the present disclosure, the generating module 23 is further configured to: according to the attribute information, assigning a first general field including a first set sequence in the message header to generate a message header; filling a second general field and an array comprising a second set sequence in the data body according to the service data and the attribute information to generate the data body; and packaging the message header and the data body to generate a response packet.
In the embodiment of the present disclosure, the generating module 23 is further configured to: and acquiring the response state of the service request, and assigning a target general field in the first general field according to the response state.
In the embodiment of the present disclosure, the generating module 23 is further configured to: extracting configuration parameters of a first general field from the attribute information; and according to a first setting sequence, assigning the first general field based on the configuration parameters of the first general field to generate a message header.
In the embodiment of the present disclosure, the generating module 23 is further configured to: extracting the service type identifier of the service request from the attribute information; and according to a second set sequence, assigning values to the second general field based on the service type identifier, and writing the service data into the array to generate a data body.
In this embodiment of the disclosure, the receiving module 21 is further configured to: and receiving a service request sent by the client through any service interface.
Fig. 10 is a schematic structural diagram of a service request response apparatus according to an embodiment of the present disclosure, the apparatus is suitable for a client, as shown in fig. 10, the service request response apparatus 300 includes a sending module 31, a receiving module 32, and an unpacking module 33, where:
a sending module 31, configured to send a service request to a server, where the service request includes attribute information and request content;
a receiving module 32, configured to receive a response packet of a service request sent by a server, where the response message includes a message header and a data body, where the message header is generated according to attribute information, and the data body is generated according to the attribute information and service data;
and an unpacking module 33, configured to unpack the response packet to obtain the service data requested by the service request from the data body.
Fig. 11 is a schematic structural diagram of a service request response apparatus according to an embodiment of the present disclosure, the apparatus is suitable for a client, and as shown in fig. 11, the service request response apparatus 400 includes a sending module 41, a receiving module 42, and an unpacking module 43, where:
the transmitting module 31, the receiving module 32, and the unpacking module 33 have the same configuration and function as the transmitting module 41, the receiving module 42, and the unpacking module 43.
In the embodiment of the present disclosure, the unpacking module 43 is further configured to: analyzing a message header and a data body from the response message; extracting parameter values of a first general field in sequence from a message header; extracting service data from the data body in response to the parameter value of the first general field indicating that the service request response is successful; responsive to the parameter value of the first generic field indicating that the service request did not respond successfully, the response message is discarded.
In the embodiment of the present disclosure, the unpacking module 43 is further configured to: acquiring a configuration parameter value of a second general field in the data body to acquire a service type identifier of the service request; and extracting service data from an array in the data body, wherein the service type identifier is used for indicating a service interface to which the service data belongs.
In the embodiment of the present disclosure, the unpacking module 43 is further configured to: determining a target service interface corresponding to the response packet according to the service type identifier; and sending the service data to a target service interface, and processing by a service layer of the target service interface.
According to the response device for the service request, the client side initiates the service request through the interface A and the interface B respectively based on a uniform response logic, the server receives the service request of the interface A and the interface B respectively and obtains service data corresponding to the service request of the interface A and the interface B, based on a response format defined by the uniform response logic, response packets corresponding to the service request of the interface A and the service request of the interface B are generated by respectively packaging based on attribute information and the service data, and the response packets are transmitted back to the client side through the interface A and the interface B. And the client unpacks the response packet respectively based on the uniform response logic, and reads the message header and the data body in the response packet. And judging whether the response of the server is successful or not from the parameter value of the field in the message header. And if the response is determined to be successful, extracting the service data in the data body, determining a service layer for data processing based on the service type identifier, and further sending the extracted detailed service data to the corresponding service layer for data processing. And if the response is determined to be successful, discarding the service data in the data body. According to the data packaging method and device, the response logic between the server and the client is unified, and then the response format of the data packaging of the business interfaces is limited, so that the server can package different business data corresponding to different business interfaces based on the same format, the data interaction process between the server and the client is simplified, the development time of the client and the server is saved, and the development resources are effectively saved.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
FIG. 12 shows a schematic block diagram of an example electronic device 1200, which can be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 12, the apparatus 1200 includes a computing unit 1201 which can perform various appropriate actions and processes in accordance with a computer program stored in a Read Only Memory (ROM)1202 or a computer program loaded from the storage unit 12012 into a Random Access Memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the device 1200 may also be stored. The computing unit 1201, the ROM1202, and the RAM 1203 are connected to each other by a bus 1204. An input/output (I/O) interface 1205 is also connected to bus 1204.
Various components in the device 1200 are connected to the I/O interface 1205 including: an input unit 1206 such as a keyboard, a mouse, or the like; an output unit 1207 such as various types of displays, speakers, and the like; a storage unit 12012 such as a magnetic disk, an optical disk, or the like; and a communication unit 1209 such as a network card, modem, wireless communication transceiver, etc. The communication unit 1209 allows the device 1200 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 1201 may be a variety of general purpose and/or special purpose processing components having processing and computing capabilities. Some examples of the computing unit 1201 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The computing unit 1201 performs the various methods and processes described above, such as a response method of a service request. For example, in some embodiments, the method of responding to service requests may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 12012. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 1200 via the ROM1202 and/or the communication unit 1209. When the computer program is loaded into the RAM 1203 and executed by the computing unit 1201, one or more steps of the above described method of responding to a service request may be performed. Alternatively, in other embodiments, the computing unit 1201 may be configured by any other suitable means (e.g., by means of firmware) to perform the method of responding to a service request.
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server with a combined blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (23)

1. A service request response method is applicable to a server, and comprises the following steps:
receiving a service request, and acquiring attribute information and request content of the service request;
acquiring the service data requested by the service request according to the request content;
and generating a response packet according to the service data and the attribute information, and sending the response packet to a corresponding client, wherein the response packet comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data.
2. The method of claim 1, wherein the generating a response packet according to the service data and the attribute information comprises:
according to the attribute information, assigning a first general field comprising a first set sequence in the message header to generate the message header;
according to the service data and the attribute information, filling a second general field and an array which comprise a second set sequence in the data body to generate the data body;
and packaging the message header and the data body to generate the response packet.
3. The method of claim 2, wherein the method further comprises:
and acquiring a response state of the service request, and assigning a target general field in the first general field according to the response state.
4. The method according to claim 2, wherein the assigning, according to the attribute information, a first general field in the message header, which includes a set order, to generate the message header comprises:
extracting configuration parameters of the first general field from the attribute information;
and according to the first setting sequence, based on the configuration parameters of the first general field, assigning the first general field to generate the message header.
5. The method according to any one of claims 2 to 4, wherein the generating the data volume by filling a second general field and an array in sequence in the data volume according to the attribute information and the service data comprises:
extracting the service type identifier of the service request from the attribute information;
and according to the second set sequence, assigning values to the second general field based on the service type identifier, and writing the service data into the array to generate the data body.
6. The method according to any of claims 1-4, wherein said receiving a service request comprises:
and receiving the service request sent by the client through any service interface.
7. A service request response method is applicable to a client, and comprises the following steps:
sending a service request to a server, wherein the service request comprises attribute information and request content;
receiving a response packet of the service request sent by the server, wherein the response message comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data;
and unpacking the response packet to acquire the service data requested by the service request from the data body.
8. The method of claim 7, wherein the unpacking the response packet to obtain the service data requested by the service request from the data body comprises:
analyzing a message header and the data body from the response message;
extracting parameter values of a first general field in sequence from the message header;
extracting the service data from the data body in response to the parameter value of the first general field indicating that the service request response is successful;
discarding the response message in response to the parameter value of the first generic field indicating that the service request did not respond successfully.
9. The method of claim 8, wherein said extracting the traffic data from the data volume comprises:
acquiring a configuration parameter value of a second general field in the data body to acquire a service type identifier of the service request;
and extracting the service data from the array in the data body, wherein the service type identifier is used for indicating a service interface to which the service data belongs.
10. The method of claim 9, wherein after extracting the traffic data from the data structure of the response message, further comprising:
determining a target service interface corresponding to the response packet according to the service type identifier;
and sending the service data to the target service interface, and processing the service data by a service layer of the target service interface.
11. A device for responding to service request, which is applied to a server, the device comprising:
the receiving module is used for receiving a service request and acquiring attribute information and request content of the service request;
the acquisition module is used for acquiring the service data requested by the service request according to the request content;
and the generating module is used for generating a response packet according to the service data and the attribute information and sending the response packet to a corresponding client, wherein the response packet comprises a message header and a data body, the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data.
12. The apparatus of claim 11, wherein the generating means is further configured to:
according to the attribute information, assigning a first general field comprising a first set sequence in the message header to generate the message header;
according to the service data and the attribute information, filling a second general field and an array which comprise a second set sequence in the data body to generate the data body;
and packaging the message header and the data body to generate the response packet.
13. The apparatus of claim 12, wherein the generating means is further configured to:
and acquiring a response state of the service request, and assigning a target general field in the first general field according to the response state.
14. The apparatus of claim 12, wherein the generating means is further configured to:
extracting configuration parameters of the first general field from the attribute information;
and according to the first setting sequence, based on the configuration parameters of the first general field, assigning the first general field to generate the message header.
15. The apparatus of any of claims 12-14, wherein the means for generating is further configured to:
extracting the service type identifier of the service request from the attribute information;
and according to the second set sequence, assigning values to the second general field based on the service type identifier, and writing the service data into the array to generate the data body.
16. The apparatus according to any one of claims 11-14, wherein the receiving module is further configured to:
and receiving the service request sent by the client through any service interface.
17. A device for responding to a service request, which is applicable to a client, the device comprising:
the system comprises a sending module, a receiving module and a sending module, wherein the sending module is used for sending a service request to a server, and the service request comprises attribute information and request content;
a receiving module, configured to receive a response packet of the service request sent by the server, where the response message includes a message header and a data body, where the message header is generated according to the attribute information, and the data body is generated according to the attribute information and the service data;
and the unpacking module is used for unpacking the response packet to acquire the service data requested by the service request from the data body.
18. The apparatus of claim 17, wherein the unpacking module is further configured to:
analyzing a message header and the data body from the response message;
extracting parameter values of a first general field in sequence from the message header;
extracting the service data from the data body in response to the parameter value of the first general field indicating that the service request response is successful;
discarding the response message in response to the parameter value of the first generic field indicating that the service request did not respond successfully.
19. The apparatus of claim 18, wherein the unpacking module is further configured to:
acquiring a configuration parameter value of a second general field in the data body to acquire a service type identifier of the service request;
and extracting the service data from the array in the data body, wherein the service type identifier is used for indicating a service interface to which the service data belongs.
20. The apparatus of claim 19, wherein the unpacking module is further configured to:
determining a target service interface corresponding to the response packet according to the service type identifier;
and sending the service data to the target service interface, and processing the service data by a service layer of the target service interface.
21. An electronic device comprising a processor and a memory;
wherein the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory for implementing the method according to any one of claims 1-6 and 7-10.
22. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, is adapted to carry out the method of any one of claims 1-6 and 7-10.
23. A computer program product, characterized in that when executed by an instruction processor in the computer program product implements the method according to any one of claims 1-6 and 7-10.
CN202110864008.2A 2021-07-29 2021-07-29 Service request response method and device and electronic equipment Pending CN113676521A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110864008.2A CN113676521A (en) 2021-07-29 2021-07-29 Service request response method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110864008.2A CN113676521A (en) 2021-07-29 2021-07-29 Service request response method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN113676521A true CN113676521A (en) 2021-11-19

Family

ID=78540686

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110864008.2A Pending CN113676521A (en) 2021-07-29 2021-07-29 Service request response method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN113676521A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115514806A (en) * 2022-11-16 2022-12-23 江苏曼荼罗软件股份有限公司 Perception discovery method and system for discrete service cluster

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080114881A1 (en) * 2006-11-13 2008-05-15 Seung-Young Lee Method and system for establishing session for message communication between converged ip messaging service client and short messaging service client
US20140040460A1 (en) * 2012-07-31 2014-02-06 Fujitsu Limited Transaction data acquisition method, recording medium, and information processing apparatus
CN105306587A (en) * 2015-11-13 2016-02-03 网易(杭州)网络有限公司 Service data processing method, service data processing device and service data processing system
CN105338104A (en) * 2015-11-19 2016-02-17 上海熙菱信息技术有限公司 Business request responding method, analysis method and analysis system
CN107637052A (en) * 2017-08-02 2018-01-26 福建联迪商用设备有限公司 A kind of business data processing method, client, service end and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080114881A1 (en) * 2006-11-13 2008-05-15 Seung-Young Lee Method and system for establishing session for message communication between converged ip messaging service client and short messaging service client
US20140040460A1 (en) * 2012-07-31 2014-02-06 Fujitsu Limited Transaction data acquisition method, recording medium, and information processing apparatus
CN105306587A (en) * 2015-11-13 2016-02-03 网易(杭州)网络有限公司 Service data processing method, service data processing device and service data processing system
CN105338104A (en) * 2015-11-19 2016-02-17 上海熙菱信息技术有限公司 Business request responding method, analysis method and analysis system
CN107637052A (en) * 2017-08-02 2018-01-26 福建联迪商用设备有限公司 A kind of business data processing method, client, service end and system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
彭东: "《SQL Server 2000应用开发技术指南》", 31 May 2001, 清华大学出版社, pages: 618 - 619 *
蒋贵全: "《VoWLAN终端原理及WLAN组网》", 31 December 2009, 国防工业出版社, pages: 52 - 54 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115514806A (en) * 2022-11-16 2022-12-23 江苏曼荼罗软件股份有限公司 Perception discovery method and system for discrete service cluster
CN115514806B (en) * 2022-11-16 2023-03-03 江苏曼荼罗软件股份有限公司 Perception discovery method and system for discrete service cluster

Similar Documents

Publication Publication Date Title
CN112866391A (en) Message pushing method and device, electronic equipment and storage medium
CN109669787B (en) Data transmission method and device, storage medium and electronic equipment
CN114500690A (en) Interface data processing method and device, electronic equipment and storage medium
CN112181542A (en) Function calling method and device, electronic equipment and storage medium
CN114911598A (en) Task scheduling method, device, equipment and storage medium
CN113676521A (en) Service request response method and device and electronic equipment
CN114389969A (en) Client test method and device, electronic equipment and storage medium
CN113010381A (en) Method and equipment for managing components
CN116932147A (en) Streaming job processing method and device, electronic equipment and medium
CN115599571A (en) Data processing method and device, electronic equipment and storage medium
CN113839964B (en) Communication method for gateway device and gateway device
CN112235411B (en) Server communication method, device, equipment and medium of RPA flow control terminal based on AI
CN113890865A (en) Data packet forwarding method and equipment
CN113905040A (en) File transmission method, device, system, equipment and storage medium
CN113051510A (en) Interactive processing method and device, front-end equipment, back-end equipment and storage medium
CN112910910A (en) Method, device, equipment and storage medium for processing OPCDA protocol message
CN113760482A (en) Task processing method, device and system
CN114448703B (en) Request processing method, request processing device, electronic equipment and storage medium
CN114461502B (en) Model monitoring method and device
CN113220282B (en) Development processing method, device and storage medium for applet
CN113360382A (en) Test method, device, equipment and storage medium
CN117041191A (en) Task execution method and device in instant messaging and electronic equipment
CN116016663A (en) Request processing method, vehicle-mounted terminal, proxy server and service processing system
CN114185673A (en) Distributed resource scheduling method, device and system
CN114201564A (en) Map production task processing method and device, electronic equipment and storage medium

Legal Events

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