CN108737474A - The method, apparatus that HTTP interface calls - Google Patents

The method, apparatus that HTTP interface calls Download PDF

Info

Publication number
CN108737474A
CN108737474A CN201710265387.7A CN201710265387A CN108737474A CN 108737474 A CN108737474 A CN 108737474A CN 201710265387 A CN201710265387 A CN 201710265387A CN 108737474 A CN108737474 A CN 108737474A
Authority
CN
China
Prior art keywords
interface
http interface
http
class
rule
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.)
Granted
Application number
CN201710265387.7A
Other languages
Chinese (zh)
Other versions
CN108737474B (en
Inventor
秦勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710265387.7A priority Critical patent/CN108737474B/en
Publication of CN108737474A publication Critical patent/CN108737474A/en
Application granted granted Critical
Publication of CN108737474B publication Critical patent/CN108737474B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/561Adding application-functional data or data for application control, e.g. adding metadata
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/1066Session management
    • H04L65/1073Registration or de-registration
    • 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
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • 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
    • H04L67/133Protocols for remote procedure calls [RPC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Library & Information Science (AREA)
  • Business, Economics & Management (AREA)
  • General Business, Economics & Management (AREA)
  • Multimedia (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the present invention provides the method, apparatus that a kind of HTTP interface calls, and can solve during being developed using third party's kit, and the code degree of coupling is high, flexibility, maintainability, can readability difference problem.This method includes:When client terminal start-up, hypertext transfer protocol HTTP interface is scanned according to configuration class.path and packet path, acquisition can call HTTP interface;HTTP interface is called to carry out agency of trademark registration to described.

Description

The method, apparatus that HTTP interface calls
Technical field
The present invention relates to the method, apparatus that field of computer technology more particularly to a kind of HTTP interface are called.
Background technology
HTTP (HyperText Transfer Protocol, hypertext transfer protocol) is that a set of computer passes through network The rule communicated, when client call service end, server-side provides HTTP interface, and client is needed according to different URL and required parameter write different hard codes, at this point, if there is many different interfaces just need individually to compile for each interface A HTTP request code is write, it is very dumb.
Currently, most common solution is to provide a public request tool-class, third party is used in daily exploitation When data, third party may provide several ways and obtain data, such as HTTP modes, far call mode.Usual HTTP modes It is most simply, most by research staff to favor, when obtaining data using HTTP modes, needs using thirds such as HttpClient Square kit is handled, and calls third party kit every time.
In realizing process of the present invention, inventor has found that at least there are the following problems in the prior art:
1. for practicability, to support HTTP request, response using third party's kit, it has to receive its towards The characteristics of process, i.e. the code degree of coupling, are high, whenever having interface to change, need to change a large amount of code, it is likely that can be because Cause to change BUG for kit and service logic coupling;
2. for complexity angle, the addresses HTTP URL, required parameter complexity it is various cause flexibility poor, request ginseng Number, response contents safety problem all can give request every time to bring fatal problem;
3. for feasibility angle, procedure-oriented exploitation is to need to change the research and development custom of developer, can safeguarded Property and can it is readability on face big challenge.
Therefore, during being developed using third party's kit, the code degree of coupling is high, flexibility, maintainability, Can readability difference, do not meet Java and advocate object-oriented and the standard towards interface exploitation, meanwhile, in system resource and people All there is larger wastes in terms of power, time cost.
Invention content
In view of this, the embodiment of the present invention provides a kind of method, apparatus, electronic equipment and readable Jie that HTTP interface calls Matter can solve during being developed using third party's kit, and the code degree of coupling is high, flexibility, maintainability, can The problem of readability difference.
To achieve the above object, one side according to the ... of the embodiment of the present invention provides a kind of side that HTTP interface calls Method.
The method that a kind of HTTP interface of the embodiment of the present invention calls includes:When client terminal start-up, according to configuration class road Diameter and packet path are scanned hypertext transfer protocol HTTP interface, and acquisition can call HTTP interface;It is called to described HTTP interface carries out agency of trademark registration.
Optionally, the method further includes:The HTTP interface is defined and adds note mark.
Optionally, to the HTTP interface be defined including:The HTTP interface is defined according to definition rule, The definition rule includes:Interface class definition rule, method rule, parametric classification rule, method parameter rule.
Optionally, the agency of trademark registration includes:Obtain the note mark of the HTTP interface;Search explain mark in whether It include the mark that can call HTTP interface;The HTTP interface for including the mark that can call HTTP interface is carried out Agency of trademark registration.
Optionally, the agency of trademark registration further comprises:For the example for calling HTTP interface that way of example is arranged Change information, the instantiation information include Instance Interface type, instantiation mode proxy class and whether be singleton pattern letter Breath.
To achieve the above object, another aspect according to the ... of the embodiment of the present invention provides a kind of dress that HTTP interface calls It sets.
The device that a kind of HTTP interface of the embodiment of the present invention calls includes:Acquisition module is used for when client terminal start-up, Hypertext transfer protocol HTTP interface is scanned according to configuration class.path and packet path, acquisition can call HTTP interface;Note Volume module, for calling HTTP interface to carry out agency of trademark registration to described.
Optionally, described device further includes:Definition module explains mark for being defined and adding to HTTP interface.
Optionally, the definition module is additionally operable to:The HTTP interface is defined according to definition rule, the definition Rule includes:Interface class definition rule, method rule, parametric classification rule, method parameter rule.
Optionally, the registration module is additionally operable to:Obtain the note mark of the HTTP interface;Searching to explain in mark is No includes the mark that can call HTTP interface;To include the mark that can call HTTP interface HTTP interface into Row agency of trademark registration.
Optionally, the registration module is additionally operable to:For the instantiation for calling HTTP interface that way of example the is arranged letter Breath, the instantiation information include Instance Interface type, instantiation mode proxy class and whether be singleton pattern information.
To achieve the above object, according to the ... of the embodiment of the present invention to be called in another aspect, providing a kind of realization HTTP interface Method electronic equipment.
The a kind of electronic equipment of the embodiment of the present invention includes:One or more processors;Storage device, for storing one Or multiple programs, when one or more of programs are executed by one or more of processors so that one or more of Processor realizes the method that the HTTP interface of the embodiment of the present invention calls.
To achieve the above object, another aspect according to the ... of the embodiment of the present invention, it is readable to provide a kind of non-transient computer Storage medium.
A kind of computer-readable medium of the embodiment of the present invention, is stored thereon with computer program, which is characterized in that described The method that the HTTP interface of the embodiment of the present invention calls is realized when program is executed by processor.
One embodiment in foregoing invention has the following advantages that or advantageous effect:Because using HTTP service towards interface Programming is first extracted the business at the relied on remote service end of client as interface, the business at remote service end is specific The realization class by the interface is realized to complete, when server-side realizes that the method logic of class sends variation, only need to write the industry The new realization class for logic of being engaged in need not rewrite the existing code of client-side interface, reduce the influence to system;Meanwhile using base In the project of interface programming, service logic is clear, and code is understandable, facilitates extension, maintainable strong;Further, towards interface Programming haves no need to change the exploitation custom of developer, greatly improves and promotes efficiency above, project maintainability and Maintenance cost can be greatly reduced in readability aspect, to the effective solution waste in terms of manpower, time cost.
Further effect possessed by above-mentioned non-usual optional mode adds hereinafter in conjunction with specific implementation mode With explanation.
Description of the drawings
Attached drawing does not constitute inappropriate limitation of the present invention for more fully understanding the present invention.Wherein:
Fig. 1 is the schematic diagram of the key step for the method that HTTP interface according to the ... of the embodiment of the present invention calls;
Fig. 2 is the signal of the HTTP interface scanning and registration for the method that HTTP interface according to the ... of the embodiment of the present invention calls Figure;
Fig. 3 is that HTTP interface requesting client model shows in the method that HTTP interface according to the ... of the embodiment of the present invention calls It is intended to;
Fig. 4 is the flow diagram that HTTP interface calls in the method that HTTP interface according to the ... of the embodiment of the present invention calls;
Fig. 5 is the stream that HTTP interface requesting client accesses in the method that HTTP interface according to the ... of the embodiment of the present invention calls Journey schematic diagram;
Fig. 6 is the schematic diagram of the main modular for the device that HTTP interface according to the ... of the embodiment of the present invention calls;
Fig. 7 is adapted for the structural representation of the computer system for the terminal device or server of realizing the embodiment of the present application Figure.
Specific implementation mode
It explains to the exemplary embodiment of the present invention below in conjunction with attached drawing, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, various changes and modifications can be made to the embodiments described herein, without departing from scope and spirit of the present invention.Together The description to known function and structure is omitted for clarity and conciseness in sample in following description.
The technical solution of the embodiment of the present invention first relies on client because using HTTP service interface-oriented programming The business at remote service end is extracted as interface, the business specific implementation at remote service end by the realization class of the interface come It completes, when server-side realizes that the method logic of class sends variation, need to only write the new realization class of the service logic, not need The existing code of client-side interface is rewritten, the influence to system is reduced;Meanwhile using the project based on interface programming, service logic Clearly, code is understandable, facilitates extension, maintainable strong;Further, interface-oriented programming haves no need to change opening for developer Hair custom, greatly improves the efficiency promoted above, in the maintainable of project and can greatly reduce dimension in readability aspect Cost is protected, to the effective solution waste in terms of manpower, the time cost.
Fig. 1 is the schematic diagram of the key step for the method that HTTP interface according to the ... of the embodiment of the present invention calls.
As shown in Figure 1, the method that a kind of HTTP interface of the embodiment of the present invention calls mainly includes the following steps:
Step S101:When client terminal start-up, HTTP interface is scanned according to configuration class.path and packet path, is obtained HTTP interface can be called.
When client terminal start-up, scan interface, it is adjustable to obtain satisfactory whole in specified range within the specified range With HTTP interface, it should be noted that the range of scanning can be specified by configuring class.path and packet path.
In order to make code structure clearly be convenient for follow-up maintenance and management, client fixed according to oneself required data first The HTTP interface class that justice is called.In the embodiment of the present invention, HTTP interface is defined and adds note mark.
In embodiments of the present invention, HTTP interface is defined and HTTP interface can be determined according to definition rule Justice, definition rule include:Interface class definition rule, method rule, parametric classification rule, method parameter rule.
It is that relevant business is classified, and is connect to each class definition one that client, which is defined HTTP interface, Mouthful, the address of request HTTP interface and parameter are mapped to the corresponding method of HTTP interface and parameter, request address is method name, Required parameter is method parameter, and client has been defined following several rules to HTTP interface:
One group of HTTP interface of the same category is named as an interface by 1, interface class definition rule, can be used and be explained "@ Pandora " is marked, for example, interface related to user, obtains user name and log in essential information (login name, pet name etc.), obtain User member's rank etc. is all operation related to user, may be defined as a user interface;
2, method rule, each method represents a HTTP interface, in order to simply distinguishing each HTTP request, it is specified that Each HTTP request is distinguished with a special parameter name (apiName), and when parameter is asked every time all there must be, Ke Yiyong "@PHttpPost " is explained to indicate that the secondary HTTP request is POST or GET, acquiescence is POST, can be repaiied according to actual conditions Change, for example, http://p.jd.com?ApiName=getUserBasicInfo&userName=east wind is broken, indicates to obtain and use Family is the essential information of " east wind is broken ";
3, parametric classification rule, HTTP request parameter are divided into two types, basic parameter and service parameter, and basic parameter is The necessary parameter of secondary HTTP interface request, it include apiName (HTTP interface name), safety certification Token (token, if Have turned on safety certification), signature (signature, data integrity verifying), basic parameter is transparent to developer, in addition to configuration Whether safety certification is opened, and service parameter is embodied in interface method parameter;
4, method parameter rule, method parameter are exactly the service parameter of the secondary HTTP interface request in fact, can use and explain "@PParam " expression parameter name is sequential between parameter, this characteristic is used in signature, for example, form tables Single field and value.
HTTP interface can be defined according to a kind of rule of any of the above.
Step S102:HTTP interface pair can be called to carry out agency of trademark registration.
In embodiments of the present invention, this step can be identified by obtaining the note of HTTP interface;It searches and explains in mark Whether include the mark that can call HTTP interface;To including that the HTTP interface of the mark of HTTP interface can be called to act on behalf of Registration.
After the definition to HTTP interface and addition note is completed, Selection and call HTTP interface, which can pass through, screens HTTP The note of interface identifies to complete, and agency of trademark registration is carried out to the HTTP interface for including the mark that can call HTTP interface.
In embodiments of the present invention, agency of trademark registration can by for can call HTTP interface be arranged way of example instantiation Information realization, instantiation information include Instance Interface type, instantiation mode proxy class and whether be singleton pattern information.
Fig. 2 is the signal of the HTTP interface scanning and registration for the method that HTTP interface according to the ... of the embodiment of the present invention calls Figure.
In the embodiment of the present invention, selects Spring (a kind of Java Development Frameworks of lightweight) to rely on injection mode and obtain Bean (example), it selects Spring Ioc containers to be managed HTTP interface, select note " Pandora " as can call The note of HTTP interface identifies.
In client terminal start-up, essential information when needing to load corresponding Bean and instantiated, for example load Whether the interface of which Bean, Bean is what, is singleton pattern etc., and specific HTTP interface scans and the implementation of registration It is as follows:
Step 201:Interface scans are carried out according to the packet of configuration or class.path.
When client terminal start-up, PandoraFactory (acting on behalf of factory) can be swept according to the packet or class.path of configuration into line interface It retouches.It finds and needs the HTTP interface loaded and Spring Ioc containers is entrusted to be managed.
Step 202:It is@Pandora to filter class and explain.
Spring Ioc containers, which filter class, explains the interface for being Pandora, which is just to provide server-side HTTP and connects Mouthful.
Step 203:Register Bean.
A corresponding Spring GenericBeanDefinition is defined for each HTTP interface, GenericBeanDefinition is one-stop standard bean definition (Bean definition), in addition to have specified class, Outside optional characteristic of the constructing variable value with property parameters as these other bean definition, it, which also has, passes through Flexibly parent bean definition are arranged in parentname attributes.In general, GenericBeanDefinition is used for Registering the visible bean definition of user, (visible bean definition mean can be in such bean Post-processor (post processor) is defined on definition to be operated to bean, even configures parent Name does extension and prepares).
Step 204:Setting creates Bean templates.
The instantiation when institute of PandoraFactoryBean (way of example) is set by GenericBeanDefinition The essential information needed, including Instance Interface type, instantiation mode proxy class C lass, whether be singleton pattern etc..
So far, entire interface scans, registration are fully completed, next, client can use Spring modes normal Call these interfaces.
Fig. 3 is that HTTP interface requesting client model shows in the method that HTTP interface according to the ... of the embodiment of the present invention calls It is intended to.
In the embodiment of the present invention, by HTTP interface requesting client be divided into two big function modules " nucleus module " and " Bean management ", wherein nucleus module function includes " resource distribution ", " acting on behalf of factory ", " note ", " HTTP facility packet ", " knot Fruit converter ", " safety certification ";" Bean management " template includes function " interface scans device ", " FactoryBean ", each function It is specific as follows:
1, resource information configuration is responsible in resource distribution, and main to provide HTTP request address, safety certification Token, request are super When the time configure.
2, factory is acted on behalf of, is responsible for interface dynamic proxy class and generates and call.
3, interface is explained, and provides HTTP interface note, there is three big notes "@Pandora ", "@PHttpPost ", "@at present PParam ", specific effect are as follows:
1)@Pandora, current interface is HTTP request interface for identification;Action scope is class.
2)@PHttpPost, for indicating that request is POST, other is all GET request, and it is POST to give tacit consent to, and action scope is Method.
3)@PParam, the key in service parameter key=value formats for corresponding to HTTP request.It is more according to Java Step response can not know the name of method parameter, so come acquisition methods parameter nomenclature by way of showing defined parameters note.
4, HTTP facility packet provides the client programming kit of efficient, feature-rich support http protocol.
5, result converter provides the parsing of returned data and is converted into object mainly after http response, returns at present Result object type supports four major class:Fundamental type, List, Map, PDTO, wherein PDTO, which is that the embodiment of the present invention is self-defined, to be returned Universal class is returned, supports to return to paging, object set and error message.
6, safety certification, includes mainly two kinds of functions of Token generators and signature authentication, and specific effect is as follows:
1) Token generators, provide authentication, and the identity Token only distributed with server-side can just access clothes The interface that business end provides.
2) signature authentication is used for request data completeness check, ensures that data in transmission process, are not lost and usurped Change.
7, interface scans device, for providing HTTP interface scanning, Bean definition registrations.
8, FactoryBean is mainly used for providing the instantiation mode of interface proxy object generation and object, rely on above-mentioned Act on behalf of factory to generate proxy class.
Fig. 4 is the execution flow signal that HTTP interface calls in the method that HTTP interface according to the ... of the embodiment of the present invention calls Figure.
Step 401:When needing to call HTTP interface, method corresponding with HTTP interface, this method meeting are just directly invoked Instantiating mode according to the Bean of registration calls the getObject methods of PandoraFactoryBean (example class) to obtain Bean Instance objects.
The getObject method calls of PandoraFactoryBean act on behalf of the newPandoraProxy methods of factory class, This method mainly generates proxy class according to JDK dynamic proxies and executes.
Step 402:The newPandoraProxy methods of factory class are acted on behalf of, the Proxy (generations for calling JDK dynamic proxies to provide Manage server) class newProxyInstance static methods, and be passed to Classloader, proxy class interface Class and need to locate The readjustment InvocationHandler of reason.
Step 403:Proxy.getProxyClas method call ProxyGenerator.generatePr oxyClass Method has parametric configuration function proxy class $ Proxy0 according to interface generation and inherits Pro xy, constructed fuction parameter InvocationHandler。
PandoraProxy classes realize InvocationHandler interfaces, $ Proxy0 proxy class tune InvocationHandler invoke methods are exactly to call PandoraProxy class invoke methods in fact.
Step 404:The side execute of PandoraProxy class invoke method calls PandoraMethod (method) class Method, and the incoming interface method to be executed and parameter.
Step 405:Execute method call buildBasicParams and buildBussiParams methods generate base This parameter and service parameter.
Basic parameter includes that apiName (method name of interface), authentication Token (are tested according to whether server-side opens Card, to determine the need for being added the parameter), signature (ensure transmission process data integrity);
Service parameter is converted to http body key=value formats and orderly, and parameter name (key) is from interface method "@PParam " explain and obtain, when sources value and calling interface method incoming value.Value supports basic data type, String, array, JSON, Object.toString, PMap type.It is described above several to notice that the data in array are also supported Type.Wherein PMap is customization type, be a kind of realization of Map structure bottoms is LinkedHashMap, can store any class Type only needs storage class to realize toString methods.PMap types, which can be automatically converted into HTTP, can set key=value Style.
The method for obtaining interface corresponding method explain the value of@PHttpPost judge this request method be POST or Otherwise GET, value are true, are POST are GET.
All preparations of this HTTP request finish, and call post the or get methods of HttpRequest tool-class (by@ PHttpPost values determine).
Step 406:The HTTP that the post/get method direct request server-sides of HttpRequest (Http requests) provide connects Port address, server-side can be a little safety certifications (if supporting safety certification) respond request returned data Res.
Res is parsed by HttpRequest, returns to String responseBody.
ResponseBody passes through result converter, returns to corresponding result object.Result object type supports that 4 is big at present Class:Fundamental type, List, Map, PDTO;PDTO is the self-defined return universal class of the present embodiment.
It is returned by method layer by layer, final result returns in initial call interface method, is used for client approach.
Fig. 5 is the stream that HTTP interface requesting client accesses in the method that HTTP interface according to the ... of the embodiment of the present invention calls Journey schematic diagram.
The embodiment of the present invention considers the coupling of system, devises the access way of no intrusion, includes mainly following three A step:
Step 501:Introduce the jar packets for including case template.
Maven modes are supported to import the jar packets comprising case template.
Step 502:Configure resource file.
Resource file includes HTTP request address, safety certification Token (it is needed to configure if server-side supports certification, Acquiescence be without configuration), the request timed out time configuration.
Step 503:Configure interface scans path.
Support packet and class.path configuration.
It should be noted that step 502 and step 503 support a kind of Spring (Java Development Frameworks of lightweight) resource File mode configures, and meets the exploitation custom of Web service developer.
The method that HTTP interface according to the ... of the embodiment of the present invention calls can be seen that because calling service using HTTP interface Interface-oriented programming defines business interface, i.e., first the business at the relied on remote service end of client is extracted as interface, The business at remote service end implements the realization class by the interface to complete, when the method logic of realization class changes When, the realization class of the service logic need to be only rewritten, without rewriting the existing code of client-side interface, is reduced to system It influences;Meanwhile using the project based on interface programming, service logic is clear, code is understandable, facilitates extension, maintainable strong;Into One step, interface-oriented programming haves no need to change the exploitation custom of developer, the efficiency promoted above is greatly improved, in item Purpose maintainability and maintenance cost can be greatly reduced in readability aspect, to effective in terms of manpower, time cost Solves waste.
Fig. 6 is the schematic diagram of the main modular for the device that HTTP interface according to the ... of the embodiment of the present invention calls;
As shown in fig. 6, the device 600 that the HTTP interface of the embodiment of the present invention calls includes:Acquisition module 601 and registration Module 602.Wherein:
Acquisition module 601 is used for when client terminal start-up, according to configuration class.path and packet path to hypertext transfer protocol HTTP interface is scanned, and acquisition can call HTTP interface;Registration module 602, for calling HTTP interface to carry out to described Agency of trademark registration.
In addition, described device further includes:Definition module explains mark for being defined and adding to HTTP interface.
The definition module is additionally operable to:The HTTP interface is defined according to definition rule, the definition rule packet It includes:Interface class definition rule, method rule, parametric classification rule, method parameter rule.
In addition, the registration module 602 is additionally operable to:Obtain the note mark of the HTTP interface;It searches and explains in mark Whether include the mark that can call HTTP interface;To including the HTTP interface of the mark that can call HTTP interface Carry out agency of trademark registration.
In addition, the registration module 602 is additionally operable to:For the instantiation for calling HTTP interface that way of example the is arranged letter Breath, the instantiation information include Instance Interface type, instantiation mode proxy class and whether be singleton pattern information.
The device that HTTP interface according to the ... of the embodiment of the present invention calls can be seen that because calling service using HTTP interface Interface-oriented programming defines business interface, i.e., first the business at the relied on remote service end of client is extracted as interface, The business at remote service end implements the realization class by the interface to complete, when the method logic of realization class changes When, the realization class of the service logic need to be only rewritten, without rewriting the existing code of client-side interface, is reduced to system It influences;Meanwhile using the project based on interface programming, service logic is clear, code is understandable, facilitates extension, maintainable strong;Into One step, interface-oriented programming haves no need to change the exploitation custom of developer, the efficiency promoted above is greatly improved, in item Purpose maintainability and maintenance cost can be greatly reduced in readability aspect, to effective in terms of manpower, time cost Solves waste.
Below with reference to Fig. 7, it illustrates the computer systems 700 suitable for the terminal device for realizing the embodiment of the present application Structural schematic diagram.Terminal device shown in Fig. 7 is only an example, to the function of the embodiment of the present application and should not use model Shroud carrys out any restrictions.
As shown in fig. 7, computer system 700 includes central processing unit (CPU) 701, it can be read-only according to being stored in Program in memory (ROM) 702 or be loaded into the program in random access storage device (RAM) 703 from storage section 708 and Execute various actions appropriate and processing.In RAM 703, also it is stored with system 700 and operates required various programs and data. CPU 701, ROM 702 and RAM 703 are connected with each other by bus 704.Input/output (I/O) interface 705 is also connected to always Line 704.
It is connected to I/O interfaces 705 with lower component:Importation 706 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 707 of spool (CRT), liquid crystal display (LCD) etc. and loud speaker etc.;Storage section 708 including hard disk etc.; And the communications portion 709 of the network interface card including LAN card, modem etc..Communications portion 709 via such as because The network of spy's net executes communication process.Driver 710 is also according to needing to be connected to I/O interfaces 705.Detachable media 711, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on driver 710, as needed in order to be read from thereon Computer program be mounted into storage section 708 as needed.
Particularly, according to an embodiment of the invention, the process of key step figure description above may be implemented as computer Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium On computer program, which includes program code for executing method shown in key step figure.In this way Embodiment in, which can be downloaded and installed by communications portion 709 from network, and/or from detachable Medium 711 is mounted.When the computer program is executed by central processing unit (CPU) 701, executes and limited in the system of the application Fixed above-mentioned function.
It should be noted that computer-readable medium shown in the application can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two arbitrarily combines.Computer readable storage medium for example can be --- but not Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or arbitrary above combination.Meter The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to:Electrical connection with one or more conducting wires, just It takes formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type and may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device, Or above-mentioned any appropriate combination.In this application, can be any include computer readable storage medium or storage journey The tangible medium of sequence, the program can be commanded the either device use or in connection of execution system, device.And at this In application, computer-readable signal media may include in a base band or as the data-signal that a carrier wave part is propagated, Wherein carry computer-readable program code.Diversified forms may be used in the data-signal of this propagation, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By instruction execution system, device either device use or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to:Wirelessly, electric wire, optical cable, RF etc. or above-mentioned Any appropriate combination.
Flow chart in attached drawing and block diagram, it is illustrated that according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part for a part for one module, program segment, or code of table, above-mentioned module, program segment, or code includes one or more Executable instruction for implementing the specified logical function.It should also be noted that in some implementations as replacements, institute in box The function of mark can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are practical On can be basically executed in parallel, they can also be executed in the opposite order sometimes, this is depended on the functions involved.Also it wants It is noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart, can use and execute rule The dedicated hardware based systems of fixed functions or operations is realized, or can use the group of specialized hardware and computer instruction It closes to realize.
Being described in module involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described module can also be arranged in the processor, for example, can be described as:A kind of processor packet Include acquisition module and registration module.Wherein, the title of these modules does not constitute the limit to the module itself under certain conditions It is fixed, for example, registration module is also described as " to the module for calling HTTP interface to carry out agency of trademark registration ".
As on the other hand, present invention also provides a kind of computer-readable medium, which can be Included in equipment described in above-described embodiment;Can also be individualism, and without be incorporated the equipment in.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes Obtaining the equipment includes:
Step S101:When client terminal start-up, HTTP interface is scanned according to configuration class.path and packet path, is obtained HTTP interface can be called.
Step S102:HTTP interface pair can be called to carry out agency of trademark registration.
Technical solution according to the ... of the embodiment of the present invention, because calling service orientation interface programming, definition using HTTP interface Business interface is first extracted the business at the relied on remote service end of client as interface, the business at remote service end The realization class by the interface is implemented to complete, when realizing that the method logic of class changes, only need to rewrite this The realization class of service logic reduces the influence to system without rewriting the existing code of client-side interface;Meanwhile using base In the project of interface programming, service logic is clear, and code is understandable, facilitates extension, maintainable strong;Further, towards interface Programming haves no need to change the exploitation custom of developer, greatly improves and promotes efficiency above, project maintainability and Maintenance cost can be greatly reduced in readability aspect, to the effective solution waste in terms of manpower, time cost.
Above-mentioned specific implementation mode, does not constitute limiting the scope of the invention.Those skilled in the art should be bright It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and replacement can occur.It is any Modifications, equivalent substitutions and improvements made by within the spirit and principles in the present invention etc., should be included in the scope of the present invention Within.

Claims (12)

1. a kind of method that HTTP interface calls, which is characterized in that including:
When client terminal start-up, hypertext transfer protocol HTTP interface is scanned according to configuration class.path and packet path, is obtained HTTP interface can be called by taking;
HTTP interface is called to carry out agency of trademark registration to described.
2. according to the method described in claim 1, it is characterized in that, the method further includes:
The HTTP interface is defined and adds note mark.
3. according to the method described in claim 2, it is characterized in that, to the HTTP interface be defined including:
The HTTP interface is defined according to definition rule, the definition rule includes:Interface class definition rule, method rule Then, parametric classification rule, method parameter rule.
4. according to the method described in claim 2, it is characterized in that, the agency of trademark registration includes:
Obtain the note mark of the HTTP interface;
Whether search in note mark includes the mark that can call HTTP interface;
Agency of trademark registration is carried out to the HTTP interface for including the mark that can call HTTP interface.
5. according to the method described in claim 4, it is characterized in that, the agency of trademark registration further comprises:
For the instantiation information for calling HTTP interface that way of example is arranged, the instantiation information includes Instance Interface class Type, instantiation mode proxy class and whether be singleton pattern information.
6. the device that a kind of HTTP interface calls, which is characterized in that including:
Acquisition module, for when client terminal start-up, being connect to hypertext transfer protocol HTTP according to configuration class.path and packet path Mouth is scanned, and acquisition can call HTTP interface;
Registration module, for calling HTTP interface to carry out agency of trademark registration to described.
7. device according to claim 6, which is characterized in that described device definition module be additionally operable to include:
Definition module explains mark for being defined and adding to HTTP interface.
8. device according to claim 7, which is characterized in that the definition module is additionally operable to:
The HTTP interface is defined according to definition rule, the definition rule includes:Interface class definition rule, method rule Then, parametric classification rule, method parameter rule.
9. device according to claim 7, which is characterized in that the registration module is additionally operable to:
Obtain the note mark of the HTTP interface;
Whether search in note mark includes the mark that can call HTTP interface;
Agency of trademark registration is carried out to the HTTP interface for including the mark that can call HTTP interface.
10. according to the method described in claim 9, it is characterized in that, the registration module is additionally operable to:
For the instantiation information for calling HTTP interface that way of example is arranged, the instantiation information includes Instance Interface class Type, instantiation mode proxy class and whether be singleton pattern information.
11. the electronic equipment that a kind of HTTP interface calls, which is characterized in that including:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors so that one or more of processors are real The now method as described in any in claim 1-5.
12. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that described program is held by processor The method as described in any in claim 1-5 is realized when row.
CN201710265387.7A 2017-04-21 2017-04-21 HTTP interface calling method and device Active CN108737474B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710265387.7A CN108737474B (en) 2017-04-21 2017-04-21 HTTP interface calling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710265387.7A CN108737474B (en) 2017-04-21 2017-04-21 HTTP interface calling method and device

Publications (2)

Publication Number Publication Date
CN108737474A true CN108737474A (en) 2018-11-02
CN108737474B CN108737474B (en) 2021-04-30

Family

ID=63933899

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710265387.7A Active CN108737474B (en) 2017-04-21 2017-04-21 HTTP interface calling method and device

Country Status (1)

Country Link
CN (1) CN108737474B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111400058A (en) * 2020-03-06 2020-07-10 中国平安人寿保险股份有限公司 Method and device for calling message, computer equipment and storage medium
CN113626225A (en) * 2021-10-11 2021-11-09 中航金网(北京)电子商务有限公司 Program calling method, terminal device and medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004034648A2 (en) * 2002-10-03 2004-04-22 Cisco Technology, Inc. Method for a wireless station to determine network metrics prior to associating with an access point
CN1883177A (en) * 2003-12-09 2006-12-20 思科技术公司 Methods and apparatus for implementing a speed sensitive mobile router
CN102096631A (en) * 2009-12-11 2011-06-15 华为技术有限公司 Interface testing method and device
CN102479077A (en) * 2010-11-26 2012-05-30 金蝶软件(中国)有限公司 Method and device for dynamically constructing function operation, and application system
CN103049306A (en) * 2011-09-12 2013-04-17 微软公司 Simulation of static members and parameterized constructors on an interface-based api
CN103501308A (en) * 2011-12-22 2014-01-08 德商赛克公司 Distributed cloud application deployment systems and/or associated methods

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004034648A2 (en) * 2002-10-03 2004-04-22 Cisco Technology, Inc. Method for a wireless station to determine network metrics prior to associating with an access point
CN1883177A (en) * 2003-12-09 2006-12-20 思科技术公司 Methods and apparatus for implementing a speed sensitive mobile router
CN102096631A (en) * 2009-12-11 2011-06-15 华为技术有限公司 Interface testing method and device
CN102479077A (en) * 2010-11-26 2012-05-30 金蝶软件(中国)有限公司 Method and device for dynamically constructing function operation, and application system
CN103049306A (en) * 2011-09-12 2013-04-17 微软公司 Simulation of static members and parameterized constructors on an interface-based api
CN103501308A (en) * 2011-12-22 2014-01-08 德商赛克公司 Distributed cloud application deployment systems and/or associated methods

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111400058A (en) * 2020-03-06 2020-07-10 中国平安人寿保险股份有限公司 Method and device for calling message, computer equipment and storage medium
CN111400058B (en) * 2020-03-06 2024-06-04 中国平安人寿保险股份有限公司 Method, device, computer equipment and storage medium for calling message
CN113626225A (en) * 2021-10-11 2021-11-09 中航金网(北京)电子商务有限公司 Program calling method, terminal device and medium

Also Published As

Publication number Publication date
CN108737474B (en) 2021-04-30

Similar Documents

Publication Publication Date Title
CN110442524A (en) It is a kind of for have Certificate Authority web service interface test method and device
US8219970B2 (en) XML push and remote execution of a wireless applications
CN110310034A (en) A kind of service orchestration applied to SaaS, business flow processing method and apparatus
US20030078960A1 (en) Architecture and process for creating software applications for multiple domains
CN107203376A (en) A kind of enterprise-level information system
CN107179984A (en) A kind of interface mock methods and interface test method
CA2915619A1 (en) Method and apparatus for customized software development kit (sdk) generation
CN106686023A (en) Flow designing method, client machine, server side apparatus and system
CN113238740B (en) Code generation method, code generation device, storage medium and electronic device
CN113987541A (en) Data access control method and device and electronic equipment
CN112187558A (en) Data verification method and device and electronic equipment
CN109981322A (en) The method and apparatus of cloud resource management based on label
CN105871911A (en) Service calling engine, method and system
CN111444090B (en) Contract testing method and device in blockchain, electronic equipment and storage medium
CN113742005A (en) Platform docking method and device
CN109446648A (en) Service of simulation method for building up and device
CN108737474A (en) The method, apparatus that HTTP interface calls
CN109104368A (en) A kind of request connection method, device, server and computer readable storage medium
Falazi et al. Unified integration of smart contracts through service orientation
CN113157523B (en) Service monitoring method and device, computer equipment and storage medium
Jensen Beginning Azure IoT Edge computing: extending the cloud to the intelligent edge
CN110780915B (en) Data processing method, device and storage medium
CN109981546A (en) The method and apparatus for obtaining the far call relationship between application module
CN107222365A (en) Data processing method, device and server
CN109992957A (en) The methods, devices and systems that templating calculates

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
GR01 Patent grant
GR01 Patent grant