WO2019104973A1 - Cross-language invoking method, server, and storage medium - Google Patents

Cross-language invoking method, server, and storage medium Download PDF

Info

Publication number
WO2019104973A1
WO2019104973A1 PCT/CN2018/089135 CN2018089135W WO2019104973A1 WO 2019104973 A1 WO2019104973 A1 WO 2019104973A1 CN 2018089135 W CN2018089135 W CN 2018089135W WO 2019104973 A1 WO2019104973 A1 WO 2019104973A1
Authority
WO
WIPO (PCT)
Prior art keywords
class
interface
service
address
memory
Prior art date
Application number
PCT/CN2018/089135
Other languages
French (fr)
Chinese (zh)
Inventor
李刚
刘汉玉
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019104973A1 publication Critical patent/WO2019104973A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • 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/08Protocols for interworking; Protocol conversion
    • H04L69/085Protocols for interworking; Protocol conversion specially adapted for interworking of IP-based networks with other networks

Definitions

  • the present application relates to the field of service invocation, and in particular, to a cross-language calling method, a server, and a computer readable storage medium.
  • Dubbo is a distributed service framework based on Facebook's open source, dedicated to improving performance and transparent remote procedure call protocol (RPC) service invocation scheme, and Service-Oriented Architecture (Service-Oriented Architecture, SOA) governance program.
  • RPC remote procedure call protocol
  • SOA Service-Oriented Architecture
  • the service platform based on the dubbo framework in the industry does not support cross-language service calls. That is to say, in the service platform based on the dubbo framework, the service party can only provide services using the java language, and the requesting party can only use the java language to invoke the service. This makes the service call language single, limiting service calls.
  • the present application provides a cross-language calling method, a server, and a computer readable storage medium, which are compatible with languages such as java, C++, python, ruby, etc., and perform cross-language calls.
  • the present application provides a cross-language calling method, the method comprising:
  • the service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
  • the present application also provides a server, the server comprising: a memory, a processor, and a cross-language calling program stored on the memory and executable on the processor, the cross-language calling program being processed
  • the device is executed to implement the following steps:
  • the service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
  • the present application further provides a computer readable storage medium including a cross-language calling program, which is implemented as described above when executed by a processor Call any step in the method across languages.
  • the cross-language calling method, the server and the computer readable storage medium proposed by the application by receiving the interface information of the servant, the host cluster IP address and the port address, write the servant's host cluster IP address and port address into the registration center, and then Create an interface class according to the interface information, save to the memory, call the class loader to load the interface class from the memory into the memory, and then query the service information provided by the service party from the registry according to the interface information, and create a proxy class corresponding to the interface class.
  • a unique URL is generated, and finally the service call request in the http protocol format sent by the requester is received, and the service call request is converted from the http protocol format to the hessian protocol format, and the corresponding proxy class is found according to the URL address in the call request.
  • the corresponding invoker entity is found, and the invoker protocol sends the service call request of the hessian protocol format to the corresponding host of the service party to initiate a service access request, and the hessian protocol is an open source and a general protocol.
  • the service party can implement services in multiple languages such as C, C++, PHYTHON, etc., thereby solving the problem that the service party and the requester invoke a single language, and realize cross-language invocation.
  • FIG. 1 is a schematic diagram of a preferred embodiment of a server of the present application.
  • FIG. 2 is a schematic diagram of an application environment of a cross-language calling method
  • FIG. 3 is a block diagram showing a preferred embodiment of the cross-language calling program in FIG. 1 or FIG. 2;
  • FIG. 4 is a flow chart of a preferred embodiment of a cross-language invocation method of the present application.
  • FIG. 1 it is a schematic diagram of a preferred embodiment of the server 1 of the present application.
  • the server 1 may be a server, a smart phone, a tablet computer, a personal computer, a portable computer, and other electronic devices having computing functions.
  • the server 1 includes a memory 11, a processor 12, a network interface 13, a communication bus 14, and a cross-language invocation program 10 stored on the memory 11 and executable on the processor 12.
  • the network interface 13 can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
  • Communication bus 14 is used to implement connection communication between these components.
  • the memory 11 includes at least one type of readable storage medium.
  • the at least one type of readable storage medium may be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card type memory, or the like.
  • the memory 11 may be an internal storage unit of the server 1, such as a hard disk of the server 1.
  • the memory 11 may also be an external storage unit of the server 1, such as a plug-in hard disk equipped on the server 1, a smart memory card (SMC), and a secure digital ( Secure Digital, SD) cards, flash cards (FC cards), etc.
  • the memory 11 can be used not only for storing application software installed on the server 1 and various types of data, such as a cross-language calling program 10, a binary codec specification, etc., but also for temporarily storing Output or data to be output, such as interface classes.
  • the processor 12 in some embodiments, may be a Central Processing Unit (CPU), microprocessor or other data processing chip for running program code or processing data stored in the memory 11, such as performing cross-language calls.
  • CPU Central Processing Unit
  • microprocessor or other data processing chip for running program code or processing data stored in the memory 11, such as performing cross-language calls.
  • the server 1 may also include a display, which may be referred to as a display screen or display unit.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an Organic Light-Emitting Diode (OLED) touch sensor.
  • OLED Organic Light-Emitting Diode
  • the display is used to display information processed in the server 1 and a work interface for displaying visualizations.
  • the server 1 may further include a user interface, and the user interface may include an input unit such as a keyboard, a voice output device such as an audio, a headphone, and the like.
  • the user interface may include an input unit such as a keyboard, a voice output device such as an audio, a headphone, and the like.
  • the program code of the cross-language invocation program 10 is stored in the memory 11 as a computer storage medium, and when the processor 12 executes the program code of the cross-language invocation program 10, the following steps are implemented:
  • the service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
  • FIG. 2 it is a schematic diagram of an application environment of a cross-language invocation method.
  • the server 1 provides a service page 2 for receiving interface information, a host cluster IP address, and a port address filled in by the service party 3.
  • the interface information is obtained by the registration center 5 issuing service information before the server 3 logs in to the server 1.
  • the cross-language invoking program 10 After receiving the interface information, the host cluster IP address, and the port address filled in by the servant 3, the cross-language invoking program 10 writes the host cluster IP address and port address of the servant 3 to the registration center 5.
  • the service provider S wants to provide a face recognition service on the server, the service information is first published in the zookeeper.
  • the zookeeper After receiving the service information, the zookeeper returns an interface information to the service provider S.
  • the server S fills in the interface information, the host cluster IP address, and the port address on the service page of the server, and the server writes the host cluster IP address and port address of the face recognition of the server S to the zookeeper.
  • the cross-language caller 10 creates an interface class based on the received interface information.
  • the interface information provided by the service party includes a package name, a class name, and a method name. Therefore, the interface class defines a package name, a class name, a method name, a request parameter, and a return parameter.
  • the interface class created is to expose the service of the servant 3 to the port of the requester 4, which is convenient to call.
  • the cross-language caller 10 calls the class loader to load the interface class from local storage into virtual machine memory.
  • the generated interface class is only stored in the local memory.
  • the cross-language caller 10 loads the interface class into the virtual machine memory by calling the class loader. Suppose you need to call the interface class of the servant S, start the virtual machine, and then load the interface class of the servant S from the hard disk to the running memory of the system.
  • the cross-language invoking program 10 queries the service center-provided service information from the registry 5 based on the interface information. For example, after receiving the interface information filled in by the service party S, the cross-language invoking program queries the zookeeper for the service information about the face recognition of the service party S.
  • the cross-language caller 10 creates a proxy class corresponding to the above interface class based on the queried service information. Wherein, if there are multiple hosts providing services under the servant 3 interface, the corresponding proxy class also has multiple invoker entities associated with multiple hosts. For example, the cross-language caller automatically rewrites the dubbo initialization process based on the service information to create a dynamic proxy class corresponding to the interface class. Bind the proxy class to the interface class.
  • the cross-language caller 10 generates a unique URL based on the created proxy class.
  • the URL generation rule is to automatically generate a unique URL address according to each method name. Bind the unique URL address to the corresponding interface class.
  • the URL is the address of the web page and consists of two main parts: the protocol and the destination.
  • the agreement includes http, ftp, telnet, etc.
  • the destination can be a file name, a directory name, or the name of a computer.
  • the cross-language caller binds the unique URL address generated by the proxy class to the interface class on the virtual machine so that requester A can find the servant S when searching for the service.
  • the requesting party 4 When the requesting party 4 needs to apply for a service, the requesting party 4 sends a service invocation request in the http protocol format to the cross-language invoking program 10, and the cross-language invoking program 10 receives the service invoking request in the http protocol format issued by the requesting party 4.
  • the service invocation request is composed of a request method URI protocol/version, a request header, and a request body.
  • the requester A sends a request to the face recognition service that sends the http protocol format based on the dubbo platform.
  • the cross-language caller 10 converts the service call request from the http protocol format to the hessian protocol format.
  • the hessian is a lightweight remoting onhttp tool that provides RMI functionality using a simple method. Compared to WebService, Hessian is simpler and faster.
  • the binary RPC protocol is adopted, which is more suitable for transmitting binary data.
  • the cross-language caller 10 and the servant 3 predetermine the binary codec specification of the service call request, and the hessian binary-encodes the service call request through a predetermined binary codec specification to generate a binary code stream.
  • the URL address in the service call request is read according to the generated binary stream.
  • the hessian protocol is an open source, general-purpose protocol.
  • the requesting party 4 can make service calls to the servant 3 in various languages such as java, C++, python, and ruby.
  • the requester A's face recognition service call request is converted from the http protocol format to the hessian protocol format to generate a binary code stream.
  • the cross-language caller 10 finds the corresponding proxy class according to the URL address in the service call request, and then finds the corresponding invoker entity according to the correspondence between the interface class and the proxy class.
  • the dubbo platform finds the corresponding proxy class according to the URL address in the face recognition service call request, and then finds the corresponding invoker entity from the interface class according to the correspondence between the interface class and the proxy class.
  • the invoker entity sends a binary code stream of the service call request in the hessian protocol format to the host corresponding to the invoker entity, and the server 3 decodes the binary code stream requested by the service call according to a predetermined binary codec specification. , read out the service call request of the requester 4, initiate a service call.
  • the face recognition host of the service party S decodes the binary stream of the hessian protocol format by using a predetermined binary codec specification to initiate a face. Identify service calls.
  • the cross-language calling method provided by the foregoing embodiment provides a service page that receives interface information, a host cluster IP address, and a port address, writes the host cluster IP address and port address to the registration center, and creates an interface class according to the interface information to be loaded into the virtual machine.
  • the proxy information is created from the registration center to create a proxy class and generate a unique URL, and then receives the http protocol format service call request sent by the requester, converts the http protocol format into a hessian protocol format, and finds according to the URL address.
  • the corresponding interface class and the corresponding invoker entity, and finally the invoker entity sends the service call request of the hessian protocol format to the corresponding host of the service party, and is compatible with other languages for service call, and realizes cross-language call between the requester and the service party. .
  • FIG. 3 it is a block diagram of a preferred embodiment of the cross-language invocation program 10 of FIG. 1 or 2.
  • a module as referred to in this application refers to a series of computer program instructions that are capable of performing a particular function.
  • the cross-language calling program 10 includes: a receiving module 110, an interface class creating module 120, a loading module 130, a query module 140, a proxy class creating module 150, a URL generating module 160, a converting module 170, a searching module 180,
  • the sending module 190, the functions or operating steps implemented by the modules 110-190 are similar to the above, and are not described in detail herein, for example, where:
  • the receiving module 110 is configured to receive the interface information of the servant, the host cluster IP address and the port address, write the host cluster IP address and port address of the servant to the registration center, or receive a service call request in the http protocol format sent by the requesting party;
  • An interface class creation module 120 configured to create an interface class according to the interface information, and save the file to a memory
  • the loading module 130 is configured to call the class loader to load the interface class from the memory into the memory;
  • the querying module 140 is configured to query, according to the interface information, the service information provided by the service party from the registration center;
  • the proxy class creation module 150 is configured to create a proxy class corresponding to the interface class according to the queried service information
  • a URL generating module 160 configured to generate a unique URL according to the proxy class
  • the conversion module 170 is configured to convert the service call request from the http protocol format to the hessian protocol format
  • the searching module 180 is configured to find a corresponding proxy class according to the URL address in the calling request, and find a corresponding invoker entity according to the correspondence between the proxy class and the interface class;
  • the sending module 190 is configured to send, by the invoker entity, a service invocation request in a hessian protocol format to a corresponding host of the service party to initiate a service access request.
  • FIG. 4 it is a flow chart of a preferred embodiment of the cross-language invocation method of the present application.
  • Step S10 receiving the interface information of the servant, the host cluster IP address, and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
  • Step S20 creating an interface class according to the interface information, and saving to the memory
  • Step S30 calling the class loader to load the interface class from the memory into the memory;
  • Step S40 Query, according to the interface information, the service information provided by the service party from the registration center;
  • Step S50 Create a proxy class corresponding to the interface class according to the queried service information.
  • Step S60 generating a unique URL according to the proxy class
  • Step S70 receiving a service call request in the http protocol format sent by the requesting party;
  • Step S80 converting the service call request from the http protocol format to the hessian protocol format
  • Step S90 Find a corresponding proxy class according to the URL address in the call request, and find a corresponding invoker entity according to the correspondence between the proxy class and the interface class;
  • Step S100 The invoker entity sends a service invocation request in the hessian protocol format to the corresponding host of the service party to initiate a service access request.
  • FIG. 2 it is a schematic diagram of an application environment of a cross-language invocation method.
  • the server 1 provides a service page 2 for receiving interface information, a host cluster IP address, and a port address filled in by the service party 3.
  • the interface information is obtained by the registration center 5 issuing service information before the server 3 logs in to the server 1.
  • the cross-language invoking program 10 After receiving the interface information, the host cluster IP address, and the port address filled in by the servant 3, the cross-language invoking program 10 writes the host cluster IP address and port address of the servant 3 to the registration center 5.
  • the service provider S wants to provide the voiceprint recognition service on the server, the service information is first published in the zookeeper.
  • the zookeeper After receiving the service information, the zookeeper returns an interface information to the service provider S.
  • the service provider S fills in the interface information, the host cluster IP address, and the port address on the service page of the server.
  • the platform writes the host cluster IP address and port address of the voice mask identified by the server S to the zookeeper.
  • the cross-language caller 10 creates an interface class based on the received interface information.
  • the interface information provided by the servant 3 includes a package name, a class name, and a method name. Therefore, the interface class defines a package name, a class name, a method name, a request parameter, and a return parameter.
  • the interface class created is to expose the service of the servant 3 to the port of the requester 4, which is convenient to call.
  • the cross-language caller 10 calls the class loader to load the interface class from local storage onto the virtual machine memory.
  • the generated interface class is only stored in the local memory.
  • the class loader is called to load the interface class into the virtual machine memory. Suppose you need to call the interface class of the servant S, start the virtual machine, and then load the interface class of the servant S from the hard disk to the running memory of the system.
  • the cross-language invoking program 10 queries the service center 3 for the service information provided from the registrar 5 based on the interface information. For example, after receiving the interface information filled in by the service provider S based on the dubbo platform, the service information of the voice sender identification of the service party S is queried in the zookeeper.
  • the cross-language caller 10 creates a proxy class corresponding to the above interface class based on the queried service information. Wherein, if there are multiple hosts providing services under the servant 3 interface, the corresponding proxy class also has multiple invoker entities associated with multiple hosts. For example, the cross-language caller automatically rewrites the dubbo initialization process based on the service information to create a dynamic proxy class corresponding to the interface class. Bind the proxy class to the interface class.
  • the cross-language caller 10 generates a unique URL based on the created proxy class.
  • the URL generation rule is to automatically generate a unique URL address according to each method name. Bind the unique URL address to the corresponding interface class.
  • the URL is the address of the web page and consists of two main parts: the protocol and the destination.
  • the agreement includes http, ftp, telnet, etc.
  • the destination can be a file name, a directory name, or the name of a computer.
  • the cross-language caller binds the unique URL address generated by the proxy class to the interface class on the virtual machine so that requester A can find the servant S when searching for the service.
  • the requesting party 4 When the requesting party 4 needs to apply for a service, the requesting party 4 sends a service invocation request in the http protocol format to the cross-language invoking program 10, and the cross-language invoking program 10 receives the service invoking request in the http protocol format issued by the requesting party 4.
  • the service invocation request is composed of a request method URI protocol/version, a request header, and a request body.
  • the requester A sends a voiceprint recognition service call request to the dubbo platform based on the http protocol format.
  • the cross-language caller 10 converts the service call request from the http protocol format to the hessian protocol format.
  • the cross-language caller 10 and the servant 3 predetermine the binary codec specification of the service call request, and the hessian binary-encodes the service call request through a predetermined binary codec specification to generate a binary code stream.
  • the URL address in the service call request is read according to the generated binary stream.
  • the hessian protocol is an open source, general-purpose protocol.
  • the requesting party 4 can make service calls to the service party 3 in various languages such as java, C++, python, ruby, and the like.
  • the cross-language caller converts the voiceprint recognition service invocation request of requester A from the http protocol format to the hessian protocol format to generate a binary code stream.
  • the cross-language invoking program 10 finds the corresponding interface class according to the URL address in the service invocation request, and then finds the corresponding invoker entity from the proxy class according to the correspondence between the interface class and the proxy class.
  • the cross-language calling program finds the corresponding proxy class according to the URL address in the voiceprint recognition service call request, and then finds the corresponding invoker entity from the interface class according to the correspondence between the interface class and the proxy class.
  • the invoker entity sends a binary code stream of the service call request in the hessian protocol format to the host corresponding to the invoker entity, and the server 3 decodes the binary code stream requested by the service call according to a predetermined binary codec specification. , read out the service call request of the requester 4, initiate a service call.
  • the voiceprint recognition host of the service party S decodes the binary code stream of the hessian protocol format by using a predetermined binary codec specification, and initiates a voiceprint. Identify service calls.
  • the cross-language calling method in the foregoing embodiment writes the host cluster IP address and port address received by the service page into the registration center, creates an interface class according to the received interface information, loads the virtual machine into the virtual machine memory, and then queries the service according to the interface information. Information and create a proxy class to generate a unique URL, and finally convert the http protocol format that receives the service call request into a hessian protocol format, and find the corresponding invoker entity to send the service call request in the hessian protocol format to the corresponding host of the service party, so that Based on the dubbo platform, it can be compatible with Java, C++, Python, ruby and other languages to expand the scope of service calls.
  • the embodiment of the present application further provides a computer readable storage medium, where the computer readable storage medium includes a cross-language calling program 10, and when the cross-language calling program 10 is executed by the processor, the following operations are implemented:
  • the service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
  • the interface class defines an interface package name, an interface class name, a method name in the interface class, a request parameter, and a return function.
  • the service party issues service information through the registration center and obtains interface information.
  • the proxy class also includes a plurality of invoker entities associated with the plurality of hosts.
  • the URL generation rule is to automatically generate a unique URL address according to each method name.
  • the technical solution of the present application which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM as described above). , a disk, an optical disk, including a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the methods described in the various embodiments of the present application.
  • a terminal device which may be a mobile phone, a computer, a server, or a network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

A cross-language invoking method, a server, and a storage medium. The method comprises: receive interface information, a host cluster IP address, and a port address of a service side, and write the host cluster IP address and the port address of the service side into a registration center (S10); create an interface class according to the interface information, and save the interface class to a storage (S20); an invoking class loader loads the interface class to a memory (S30); inquiry, according to the interface information, service information provided by the service side from the registration center (S40); create, according to the service information, a proxy class corresponding to the interface class (S50); generate a unique URL according to the proxy class (S60); receive a request in an http protocol format sent from a requester (S70); convert the request into a hessian protocol format (S80); find a corresponding proxy class according to the URL address in the request, and find a corresponding invoker entity according to a corresponding relationship between the proxy class and the interface class (S90); the invoker entity sends the request in the hessian protocol format to a corresponding host of the service side to initiate a service access request (S100), so as to implement cross-language invoking.

Description

跨语言调用方法、服务器及存储介质Cross-language calling method, server and storage medium
优先权申明Priority claim
本申请要求于2017年11月30日提交中国专利局、申请号为201711239546.2,名称为“跨语言调用方法、服务器及存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合本申请中。This application claims the priority of the Chinese Patent Application entitled "Cross-Language Invoking Method, Server and Storage Media", filed on November 30, 2017, with the application number of 201711239546.2, the entire contents of which are incorporated by reference. The way it is combined with this application.
技术领域Technical field
本申请涉及服务调用领域,尤其涉及一种跨语言调用方法、服务器及计算机可读存储介质。The present application relates to the field of service invocation, and in particular, to a cross-language calling method, a server, and a computer readable storage medium.
背景技术Background technique
dubbo是一种基于阿里巴巴开源的分布式服务框架,致力于提高性能和透明化的远程过程调用协议(Remote Procedure Call Protocol,RPC)服务调用方案,以及面向服务的体系结构(Service-Oriented Architecture,SOA)治理方案。目前,业内基于dubbo框架的服务平台,不支持跨语言的服务调用。也就是说,在基于dubbo框架的服务平台,服务方只能使用java语言提供服务,请求方也只能使用java语言来调用服务。这样使得服务调用语言单一,限制了服务调用。Dubbo is a distributed service framework based on Alibaba's open source, dedicated to improving performance and transparent remote procedure call protocol (RPC) service invocation scheme, and Service-Oriented Architecture (Service-Oriented Architecture, SOA) governance program. Currently, the service platform based on the dubbo framework in the industry does not support cross-language service calls. That is to say, in the service platform based on the dubbo framework, the service party can only provide services using the java language, and the requesting party can only use the java language to invoke the service. This makes the service call language single, limiting service calls.
发明内容Summary of the invention
鉴于以上内容,本申请提供一种跨语言调用方法、服务器及计算机可读存储介质,能够兼容java、C++、python、ruby等语言进行RPC调用,实现跨语言调用。In view of the above, the present application provides a cross-language calling method, a server, and a computer readable storage medium, which are compatible with languages such as java, C++, python, ruby, etc., and perform cross-language calls.
为实现上述目的,本申请提供一种跨语言调用方法,该方法包括:To achieve the above objective, the present application provides a cross-language calling method, the method comprising:
接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心;Receiving the interface information of the servant, the host cluster IP address and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
根据所述接口信息创建一个接口类,保存到存储器;Creating an interface class according to the interface information, and saving to the memory;
调用类加载器将接口类从存储器加载到内存;Calling the class loader to load the interface class from memory into memory;
根据所述接口信息从注册中心查询服务方提供的服务信息;Querying, according to the interface information, the service information provided by the service party from the registration center;
根据查询到的服务信息创建一个与上述接口类对应的代理类;Creating a proxy class corresponding to the above interface class according to the service information that is queried;
根据代理类生成唯一的统一资源定位器(Uniform Resoure Locator,URL);Generate a unique Uniform Relocation Locator (URL) based on the proxy class;
接收请求方发出的http协议格式的服务调用请求;Receiving a service call request in the http protocol format issued by the requesting party;
将服务调用请求从http协议格式转换为hessian协议格式;Convert the service invocation request from the http protocol format to the hessian protocol format;
根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的调用器(invoker)实体;Find the corresponding proxy class according to the URL address in the call request, and find the corresponding invoker entity according to the correspondence between the proxy class and the interface class;
由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
此外,本申请还提供一种服务器,该服务器包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的跨语言调用程序,所述跨语言调用程序被所述处理器执行,可实现如下步骤:In addition, the present application also provides a server, the server comprising: a memory, a processor, and a cross-language calling program stored on the memory and executable on the processor, the cross-language calling program being processed The device is executed to implement the following steps:
接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心;Receiving the interface information of the servant, the host cluster IP address and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
根据所述接口信息创建一个接口类,保存到存储器;Creating an interface class according to the interface information, and saving to the memory;
调用类加载器将接口类从存储器加载到内存;Calling the class loader to load the interface class from memory into memory;
根据所述接口信息从注册中心查询服务方提供的服务信息;Querying, according to the interface information, the service information provided by the service party from the registration center;
根据查询到的服务信息创建一个与上述接口类对应的代理类;Creating a proxy class corresponding to the above interface class according to the service information that is queried;
根据代理类生成唯一的URL;Generate a unique URL based on the proxy class;
接收请求方发出的http协议格式的服务调用请求;Receiving a service call request in the http protocol format issued by the requesting party;
将服务调用请求从http协议格式转换为hessian协议格式;Convert the service invocation request from the http protocol format to the hessian protocol format;
根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;Find the corresponding proxy class according to the URL address in the call request, and find the corresponding invoker entity according to the correspondence between the proxy class and the interface class;
由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质中包括跨语言调用程序,所述跨语言调用程序被处理器执行时,可实现如上所述跨语言调用方法中的任意步骤。In addition, in order to achieve the above object, the present application further provides a computer readable storage medium including a cross-language calling program, which is implemented as described above when executed by a processor Call any step in the method across languages.
本申请提出的跨语言调用方法、服务器及计算机可读存储介质,通过接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心,然后根据接口信息创建一个接口类,保存到存储器,调用类加载器将接口类从存储器加载到内存,再根据接口信息从注 册中心查询服务方提供的服务信息,创建一个与上述接口类对应的代理类,根据代理类生成唯一的URL,最后接收请求方发出的http协议格式的服务调用请求,将服务调用请求从http协议格式转换为hessian协议格式,根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体,由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求,hessian协议是开源、通用协议,在平台和服务方实现hessian协议的情况下,服务方可以C、C++、PHYTHON等多种语言实现服务,从而解决服务方、请求方调用语言单一的问题,实现跨语言调用。The cross-language calling method, the server and the computer readable storage medium proposed by the application, by receiving the interface information of the servant, the host cluster IP address and the port address, write the servant's host cluster IP address and port address into the registration center, and then Create an interface class according to the interface information, save to the memory, call the class loader to load the interface class from the memory into the memory, and then query the service information provided by the service party from the registry according to the interface information, and create a proxy class corresponding to the interface class. According to the proxy class, a unique URL is generated, and finally the service call request in the http protocol format sent by the requester is received, and the service call request is converted from the http protocol format to the hessian protocol format, and the corresponding proxy class is found according to the URL address in the call request. According to the corresponding relationship between the proxy class and the interface class, the corresponding invoker entity is found, and the invoker protocol sends the service call request of the hessian protocol format to the corresponding host of the service party to initiate a service access request, and the hessian protocol is an open source and a general protocol. Hessian association with the service party In the case of the discussion, the service party can implement services in multiple languages such as C, C++, PHYTHON, etc., thereby solving the problem that the service party and the requester invoke a single language, and realize cross-language invocation.
附图说明DRAWINGS
图1为本申请服务器较佳实施例的示意图;1 is a schematic diagram of a preferred embodiment of a server of the present application;
图2为跨语言调用方法的应用环境示意图;2 is a schematic diagram of an application environment of a cross-language calling method;
图3为图1或图2中跨语言调用程序较佳实施例的模块示意图;3 is a block diagram showing a preferred embodiment of the cross-language calling program in FIG. 1 or FIG. 2;
图4为本申请跨语言调用方法较佳实施例的流程图。4 is a flow chart of a preferred embodiment of a cross-language invocation method of the present application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
如图1所示,是本申请服务器1较佳实施例的示意图。As shown in FIG. 1, it is a schematic diagram of a preferred embodiment of the server 1 of the present application.
在本实施例中,服务器1可以是服务器、智能手机、平板电脑、个人电脑、便携计算机以及其它具有运算功能的电子设备。In this embodiment, the server 1 may be a server, a smart phone, a tablet computer, a personal computer, a portable computer, and other electronic devices having computing functions.
该服务器1包括:存储器11、处理器12、网络接口13、通信总线14及存储在存储器11上并可在所述处理器12上运行的跨语言调用程序10。The server 1 includes a memory 11, a processor 12, a network interface 13, a communication bus 14, and a cross-language invocation program 10 stored on the memory 11 and executable on the processor 12.
其中,网络接口13可选地可以包括标准的有线接口、无线接口(如WI-FI接口)。通信总线14用于实现这些组件之间的连接通信。The network interface 13 can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). Communication bus 14 is used to implement connection communication between these components.
存储器11至少包括一种类型的可读存储介质。所述至少一种类型的可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器等的非易失性存储介质。 在一些实施例中,所述存储器11可以是所述服务器1的内部存储单元,例如该服务器1的硬盘。在另一些实施例中,所述存储器11也可以是所述服务器1的外部存储单元,例如所述服务器1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card,FC)等。The memory 11 includes at least one type of readable storage medium. The at least one type of readable storage medium may be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card type memory, or the like. In some embodiments, the memory 11 may be an internal storage unit of the server 1, such as a hard disk of the server 1. In other embodiments, the memory 11 may also be an external storage unit of the server 1, such as a plug-in hard disk equipped on the server 1, a smart memory card (SMC), and a secure digital ( Secure Digital, SD) cards, flash cards (FC cards), etc.
在本实施例中,所述存储器11不仅可以用于存储安装于所述服务器1的应用软件及各类数据,例如跨语言调用程序10、二进制编解码规范等,还可以用于暂时地存储已经输出或者将要输出的数据,如接口类。In this embodiment, the memory 11 can be used not only for storing application software installed on the server 1 and various types of data, such as a cross-language calling program 10, a binary codec specification, etc., but also for temporarily storing Output or data to be output, such as interface classes.
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU),微处理器或其它数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行跨语言调用程序10的计算机程序代码和请求消息二进制的编解码等。The processor 12, in some embodiments, may be a Central Processing Unit (CPU), microprocessor or other data processing chip for running program code or processing data stored in the memory 11, such as performing cross-language calls. The computer program code of the program 10 and the codec of the request message binary, and the like.
优选地,该服务器1还可以包括显示器,显示器可以称为显示屏或显示单元。在一些实施例中显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及有机发光二极管(Organic Light-Emitting Diode,OLED)触摸器等。显示器用于显示在服务器1中处理的信息以及用于显示可视化的工作界面。Preferably, the server 1 may also include a display, which may be referred to as a display screen or display unit. In some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an Organic Light-Emitting Diode (OLED) touch sensor. The display is used to display information processed in the server 1 and a work interface for displaying visualizations.
优选地,该服务器1还可以包括用户接口,用户接口可以包括输入单元比如键盘(Keyboard)、语音输出装置比如音响、耳机等。Preferably, the server 1 may further include a user interface, and the user interface may include an input unit such as a keyboard, a voice output device such as an audio, a headphone, and the like.
在图1所示的服务器1实施例中,作为一种计算机存储介质的存储器11中存储跨语言调用程序10的程序代码,处理器12执行跨语言调用程序10的程序代码时,实现如下步骤:In the embodiment of the server 1 shown in FIG. 1, the program code of the cross-language invocation program 10 is stored in the memory 11 as a computer storage medium, and when the processor 12 executes the program code of the cross-language invocation program 10, the following steps are implemented:
接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心;Receiving the interface information of the servant, the host cluster IP address and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
根据所述接口信息创建一个接口类,保存到存储器;Creating an interface class according to the interface information, and saving to the memory;
调用类加载器将接口类从存储器加载到内存;Calling the class loader to load the interface class from memory into memory;
根据所述接口信息从注册中心查询服务方提供的服务信息;Querying, according to the interface information, the service information provided by the service party from the registration center;
根据查询到的服务信息创建一个与上述接口类对应的代理类;Creating a proxy class corresponding to the above interface class according to the service information that is queried;
根据代理类生成唯一的URL;Generate a unique URL based on the proxy class;
接收请求方发出的http协议格式的服务调用请求;Receiving a service call request in the http protocol format issued by the requesting party;
将服务调用请求从http协议格式转换为hessian协议格式;Convert the service invocation request from the http protocol format to the hessian protocol format;
根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;Find the corresponding proxy class according to the URL address in the call request, and find the corresponding invoker entity according to the correspondence between the proxy class and the interface class;
由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
本实施例中,如图2所示,是跨语言调用方法的应用环境示意图,服务器1提供一个服务页面2,该页面用于接收服务方3填写的接口信息、主机集群IP地址和端口地址。其中所述接口信息是服务方3登录服务器1前,通过注册中心5发布服务信息来获得的。跨语言调用程序10接收到服务方3填写的接口信息、主机集群IP地址和端口地址后,将服务方3的主机集群IP地址和端口地址写入注册中心5。例如,当服务方S想在该服务器提供人脸识别服务时,先在zookeeper发布服务信息。zookeeper收到服务信息后返回一个接口信息给服务方S。服务方S将接口信息、主机集群IP地址和端口地址填写在该服务器的服务页面,该服务器将服务方S处理人脸识别的主机集群IP地址和端口地址写入zookeeper。In this embodiment, as shown in FIG. 2, it is a schematic diagram of an application environment of a cross-language invocation method. The server 1 provides a service page 2 for receiving interface information, a host cluster IP address, and a port address filled in by the service party 3. The interface information is obtained by the registration center 5 issuing service information before the server 3 logs in to the server 1. After receiving the interface information, the host cluster IP address, and the port address filled in by the servant 3, the cross-language invoking program 10 writes the host cluster IP address and port address of the servant 3 to the registration center 5. For example, when the service provider S wants to provide a face recognition service on the server, the service information is first published in the zookeeper. After receiving the service information, the zookeeper returns an interface information to the service provider S. The server S fills in the interface information, the host cluster IP address, and the port address on the service page of the server, and the server writes the host cluster IP address and port address of the face recognition of the server S to the zookeeper.
跨语言调用程序10根据接收到的接口信息创建一个接口类。其中,服务方所提供的接口信息包括包名、类名和方法名等。因此,所述接口类定义了包名、类名、方法名、请求参数及返回参数。例如:The cross-language caller 10 creates an interface class based on the received interface information. The interface information provided by the service party includes a package name, a class name, and a method name. Therefore, the interface class defines a package name, a class name, a method name, a request parameter, and a return parameter. E.g:
Figure PCTCN2018089135-appb-000001
Figure PCTCN2018089135-appb-000001
再将生成的接口类保存到本地存储器,如硬盘、磁盘等。创建的接口类是将服务方3的服务暴露给请求方4的端口,方便调用。Save the generated interface class to local storage, such as hard disk, disk, and so on. The interface class created is to expose the service of the servant 3 to the port of the requester 4, which is convenient to call.
跨语言调用程序10调用类加载器将接口类从本地存储器加载至虚拟机内存。其中,所述生成的接口类只是保存在本地的存储器,需使用该接口类时,跨语言调用程序10通过调用类加载器将接口类加载到虚拟机内存。假设需要调用服务方S的接口类时,启动虚拟机,然后将服务方S的接口类从硬盘加载到系统的运行内存上。The cross-language caller 10 calls the class loader to load the interface class from local storage into virtual machine memory. The generated interface class is only stored in the local memory. When the interface class is used, the cross-language caller 10 loads the interface class into the virtual machine memory by calling the class loader. Suppose you need to call the interface class of the servant S, start the virtual machine, and then load the interface class of the servant S from the hard disk to the running memory of the system.
跨语言调用程序10根据接口信息从注册中心5查询服务方提供的服务信息。例如,跨语言调用程序接收到服务方S填写的接口信息后,在zookeeper中查询服务方S的关于人脸识别的服务信息。The cross-language invoking program 10 queries the service center-provided service information from the registry 5 based on the interface information. For example, after receiving the interface information filled in by the service party S, the cross-language invoking program queries the zookeeper for the service information about the face recognition of the service party S.
跨语言调用程序10根据查询到的服务信息创建一个与上述接口类对应的代理类。其中,服务方3接口下若有多台主机提供服务,对应的代理类也有多个invoker实体与多个主机关联。例如,跨语言调用程序根据服务信息,自动重写dubbo初始化流程,创建一个与接口类对应的动态代理类。使得代理类与接口类进行绑定。The cross-language caller 10 creates a proxy class corresponding to the above interface class based on the queried service information. Wherein, if there are multiple hosts providing services under the servant 3 interface, the corresponding proxy class also has multiple invoker entities associated with multiple hosts. For example, the cross-language caller automatically rewrites the dubbo initialization process based on the service information to create a dynamic proxy class corresponding to the interface class. Bind the proxy class to the interface class.
跨语言调用程序10根据创建的代理类生成唯一的URL。其中,URL的生成规则是根据每一个方法名自动生产一个唯一的URL地址。并将唯一的URL地址与对应的接口类进行绑定。其中URL是web页的地址,主要由两个主要的部分构成:协议和目的地。其中协议包括http、ftp、telnet等,目的地可以是某文件名、目录名或者某台计算机的名称。例如,跨语言调用程序将代理类生成的唯一的URL地址与虚拟机上的接口类进行绑定,使得请求方A在搜索服务时,能够找到服务方S。The cross-language caller 10 generates a unique URL based on the created proxy class. Among them, the URL generation rule is to automatically generate a unique URL address according to each method name. Bind the unique URL address to the corresponding interface class. The URL is the address of the web page and consists of two main parts: the protocol and the destination. The agreement includes http, ftp, telnet, etc. The destination can be a file name, a directory name, or the name of a computer. For example, the cross-language caller binds the unique URL address generated by the proxy class to the interface class on the virtual machine so that requester A can find the servant S when searching for the service.
当请求方4需要申请服务时,请求方4向跨语言调用程序10发送http协议格式的服务调用请求,跨语言调用程序10接收请求方4发出的http协议格式的服务调用请求。其中,服务调用请求由请求方法URI协议/版本、请求头、请求正文三部分组成。例如,请求方A向基于dubbo平台发送http协议格式的人脸识别服务调用请求。When the requesting party 4 needs to apply for a service, the requesting party 4 sends a service invocation request in the http protocol format to the cross-language invoking program 10, and the cross-language invoking program 10 receives the service invoking request in the http protocol format issued by the requesting party 4. The service invocation request is composed of a request method URI protocol/version, a request header, and a request body. For example, the requester A sends a request to the face recognition service that sends the http protocol format based on the dubbo platform.
跨语言调用程序10将服务调用请求从http协议格式转换为hessian协议格式。所述hessian是一个轻量级的remoting onhttp工具,使用简单的方法提供了RMI的功能。相比WebService,Hessian更简单、快捷。采用的是二进制RPC协议,比较适合于发送二进制数据。其中,跨语言调用程序10与服务方3预先确定服务调用请求的二进制编解码规范,hessian通过预先确定的二进制编解码规范将服务调用请求进行二进制编码,产生二进制码流。根据产生的二进制码流读取服务调用请求中的URL地址。其中,hessian协议是开源、通用协议,在跨语言调用程序10和服务方3实现hessian协议的情况下,请求方4可以java、C++、python、ruby等多种语言对服务方3进行服务调用。例如,基于dubbo平台将请求方A的人脸识别服务调用请求从http协议格式 转换为hessian协议格式,生成二进制码流。The cross-language caller 10 converts the service call request from the http protocol format to the hessian protocol format. The hessian is a lightweight remoting onhttp tool that provides RMI functionality using a simple method. Compared to WebService, Hessian is simpler and faster. The binary RPC protocol is adopted, which is more suitable for transmitting binary data. The cross-language caller 10 and the servant 3 predetermine the binary codec specification of the service call request, and the hessian binary-encodes the service call request through a predetermined binary codec specification to generate a binary code stream. The URL address in the service call request is read according to the generated binary stream. The hessian protocol is an open source, general-purpose protocol. In the case where the cross-language calling program 10 and the servant 3 implement the hessian protocol, the requesting party 4 can make service calls to the servant 3 in various languages such as java, C++, python, and ruby. For example, based on the dubbo platform, the requester A's face recognition service call request is converted from the http protocol format to the hessian protocol format to generate a binary code stream.
跨语言调用程序10根据服务调用请求中的URL地址找到对应的代理类,再根据接口类与代理类的对应关系找到相对应的invoker实体。例如,基于dubbo平台根据人脸识别服务调用请求中的URL地址找到对应的代理类,再根据接口类与代理类的对应关系从接口类中找到相对应的invoker实体。The cross-language caller 10 finds the corresponding proxy class according to the URL address in the service call request, and then finds the corresponding invoker entity according to the correspondence between the interface class and the proxy class. For example, the dubbo platform finds the corresponding proxy class according to the URL address in the face recognition service call request, and then finds the corresponding invoker entity from the interface class according to the correspondence between the interface class and the proxy class.
该invoker实体将hessian协议格式的服务调用请求的二进制码流发送给服务方3与该invoker实体相对应的主机,服务方3根据预先确定的二进制编解码规范对服务调用请求的二进制码流进行解码,读取出请求方4的服务调用请求,发起服务调用。例如,服务方S的人脸识别主机接收到invoker实体发送的hessian协议格式的人脸识别服务调用请求后,利用预先确定的二进制编解码规范对hessian协议格式的二进制码流进行解码,发起人脸识别服务调用。The invoker entity sends a binary code stream of the service call request in the hessian protocol format to the host corresponding to the invoker entity, and the server 3 decodes the binary code stream requested by the service call according to a predetermined binary codec specification. , read out the service call request of the requester 4, initiate a service call. For example, after receiving the face recognition service call request in the hessian protocol format sent by the invoker entity, the face recognition host of the service party S decodes the binary stream of the hessian protocol format by using a predetermined binary codec specification to initiate a face. Identify service calls.
上述实施例提出的跨语言调用方法,提供一个接收接口信息、主机集群IP地址和端口地址的服务页面,将主机集群IP地址和端口地址写入注册中心并根据接口信息创建接口类加载到虚拟机内存上,再根据接口信息从注册中心查询服务信息创建代理类并生成唯一的URL,然后接收请求方发出的http协议格式服务调用请求,将http协议格式转换为hessian协议格式,并根据URL地址找到对应的接口类,及对应的invoker实体,最后由该invoker实体将hessian协议格式的服务调用请求发送给服务方相应的主机,兼容了其它语言进行服务调用,实现请求方与服务方的跨语言调用。The cross-language calling method provided by the foregoing embodiment provides a service page that receives interface information, a host cluster IP address, and a port address, writes the host cluster IP address and port address to the registration center, and creates an interface class according to the interface information to be loaded into the virtual machine. In the memory, according to the interface information, the proxy information is created from the registration center to create a proxy class and generate a unique URL, and then receives the http protocol format service call request sent by the requester, converts the http protocol format into a hessian protocol format, and finds according to the URL address. The corresponding interface class and the corresponding invoker entity, and finally the invoker entity sends the service call request of the hessian protocol format to the corresponding host of the service party, and is compatible with other languages for service call, and realizes cross-language call between the requester and the service party. .
如图3所示,是图1或图2中跨语言调用程序10较佳实施例的模块示意图。本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段。As shown in FIG. 3, it is a block diagram of a preferred embodiment of the cross-language invocation program 10 of FIG. 1 or 2. A module as referred to in this application refers to a series of computer program instructions that are capable of performing a particular function.
在本实施例中,跨语言调用程序10包括:接收模块110、接口类创建模块120、加载模块130、查询模块140、代理类创建模块150、URL生成模块160、转换模块170、查找模块180、发送模块190,所述模块110-190所实现的功能或操作步骤均与上文类似,此处不再详述,示例性地,例如其中:In this embodiment, the cross-language calling program 10 includes: a receiving module 110, an interface class creating module 120, a loading module 130, a query module 140, a proxy class creating module 150, a URL generating module 160, a converting module 170, a searching module 180, The sending module 190, the functions or operating steps implemented by the modules 110-190 are similar to the above, and are not described in detail herein, for example, where:
接收模块110,用于接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心或接收请求方发出的http协议格式的服务调用请求;The receiving module 110 is configured to receive the interface information of the servant, the host cluster IP address and the port address, write the host cluster IP address and port address of the servant to the registration center, or receive a service call request in the http protocol format sent by the requesting party;
接口类创建模块120,用于根据所述接口信息创建一个接口类,保存到存储器;An interface class creation module 120, configured to create an interface class according to the interface information, and save the file to a memory;
加载模块130,用于调用类加载器将接口类从存储器加载到内存;The loading module 130 is configured to call the class loader to load the interface class from the memory into the memory;
查询模块140,用于根据所述接口信息从注册中心查询服务方提供的服务信息;The querying module 140 is configured to query, according to the interface information, the service information provided by the service party from the registration center;
代理类创建模块150,用于根据查询到的服务信息创建一个与上述接口类对应的代理类;The proxy class creation module 150 is configured to create a proxy class corresponding to the interface class according to the queried service information;
URL生成模块160,用于根据代理类生成唯一的URL;a URL generating module 160, configured to generate a unique URL according to the proxy class;
转换模块170,用于将服务调用请求从http协议格式转换为hessian协议格式;The conversion module 170 is configured to convert the service call request from the http protocol format to the hessian protocol format;
查找模块180,用于根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;The searching module 180 is configured to find a corresponding proxy class according to the URL address in the calling request, and find a corresponding invoker entity according to the correspondence between the proxy class and the interface class;
发送模块190,用于由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The sending module 190 is configured to send, by the invoker entity, a service invocation request in a hessian protocol format to a corresponding host of the service party to initiate a service access request.
如图4所示,是本申请跨语言调用方法较佳实施例的流程图。As shown in FIG. 4, it is a flow chart of a preferred embodiment of the cross-language invocation method of the present application.
在本实施例中,处理器12执行存储器11中存储的跨语言调用程序10的计算机程序时实现跨语言调用方法的如下步骤:In the present embodiment, when the processor 12 executes the computer program of the cross-language invocation program 10 stored in the memory 11, the following steps are implemented to implement the cross-language calling method:
步骤S10,接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心;Step S10, receiving the interface information of the servant, the host cluster IP address, and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
步骤S20,根据所述接口信息创建一个接口类,保存到存储器;Step S20, creating an interface class according to the interface information, and saving to the memory;
步骤S30,调用类加载器将接口类从存储器加载到内存;Step S30, calling the class loader to load the interface class from the memory into the memory;
步骤S40,根据所述接口信息从注册中心查询服务方提供的服务信息;Step S40: Query, according to the interface information, the service information provided by the service party from the registration center;
步骤S50,根据查询到的服务信息创建一个与上述接口类对应的代理类;Step S50: Create a proxy class corresponding to the interface class according to the queried service information.
步骤S60,根据代理类生成唯一的URL;Step S60, generating a unique URL according to the proxy class;
步骤S70,接收请求方发出的http协议格式的服务调用请求;Step S70, receiving a service call request in the http protocol format sent by the requesting party;
步骤S80,将服务调用请求从http协议格式转换为hessian协议格式;Step S80, converting the service call request from the http protocol format to the hessian protocol format;
步骤S90,根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;Step S90: Find a corresponding proxy class according to the URL address in the call request, and find a corresponding invoker entity according to the correspondence between the proxy class and the interface class;
步骤S100,由该invoker实体将hessian协议格式的服务调用请求发送给服 务方的相应主机,发起服务访问请求。Step S100: The invoker entity sends a service invocation request in the hessian protocol format to the corresponding host of the service party to initiate a service access request.
本实施例中,如图2所示,是跨语言调用方法的应用环境示意图,服务器1提供一个服务页面2,该页面用于接收服务方3填写的接口信息、主机集群IP地址和端口地址。其中所述接口信息是服务方3登录服务器1前,通过注册中心5发布服务信息来获得的。跨语言调用程序10接收到服务方3填写的接口信息、主机集群IP地址和端口地址后,将服务方3的主机集群IP地址和端口地址写入注册中心5。例如,当服务方S想在服务器提供声纹识别服务时,先在zookeeper发布服务信息。zookeeper收到服务信息后返回一个接口信息给服务方S。服务方S将接口信息、主机集群IP地址和端口地址填写在服务器的服务页面,该平台将服务方S处理声纹识别的主机集群IP地址和端口地址写入zookeeper。In this embodiment, as shown in FIG. 2, it is a schematic diagram of an application environment of a cross-language invocation method. The server 1 provides a service page 2 for receiving interface information, a host cluster IP address, and a port address filled in by the service party 3. The interface information is obtained by the registration center 5 issuing service information before the server 3 logs in to the server 1. After receiving the interface information, the host cluster IP address, and the port address filled in by the servant 3, the cross-language invoking program 10 writes the host cluster IP address and port address of the servant 3 to the registration center 5. For example, when the service provider S wants to provide the voiceprint recognition service on the server, the service information is first published in the zookeeper. After receiving the service information, the zookeeper returns an interface information to the service provider S. The service provider S fills in the interface information, the host cluster IP address, and the port address on the service page of the server. The platform writes the host cluster IP address and port address of the voice mask identified by the server S to the zookeeper.
跨语言调用程序10根据接收到的接口信息创建一个接口类。其中,服务方3所提供的接口信息包括包名、类名和方法名等。因此,所述接口类定义了包名、类名、方法名、请求参数及返回参数。例如:The cross-language caller 10 creates an interface class based on the received interface information. The interface information provided by the servant 3 includes a package name, a class name, and a method name. Therefore, the interface class defines a package name, a class name, a method name, a request parameter, and a return parameter. E.g:
Figure PCTCN2018089135-appb-000002
Figure PCTCN2018089135-appb-000002
再将生成的接口类保存到本地存储器,如硬盘、磁盘等。创建的接口类是将服务方3的服务暴露给请求方4的端口,方便调用。Save the generated interface class to local storage, such as hard disk, disk, and so on. The interface class created is to expose the service of the servant 3 to the port of the requester 4, which is convenient to call.
跨语言调用程序10调用类加载器将接口类从本地存储器加载至虚拟机内存上。其中,所述生成的接口类只是保存在本地的存储器,需要使用该接口类时,调用类加载器将接口类加载到虚拟机内存。假设需要调用服务方S的接口类时,启动虚拟机,然后将服务方S的接口类从硬盘加载到系统的运行内存上。The cross-language caller 10 calls the class loader to load the interface class from local storage onto the virtual machine memory. The generated interface class is only stored in the local memory. When the interface class is needed, the class loader is called to load the interface class into the virtual machine memory. Suppose you need to call the interface class of the servant S, start the virtual machine, and then load the interface class of the servant S from the hard disk to the running memory of the system.
跨语言调用程序10根据接口信息从注册中心5查询服务方3提供的服务信息。例如,基于dubbo平台接收到服务方S填写的接口信息后,在zookeeper中查询服务方S的关于声纹识别的服务信息。The cross-language invoking program 10 queries the service center 3 for the service information provided from the registrar 5 based on the interface information. For example, after receiving the interface information filled in by the service provider S based on the dubbo platform, the service information of the voice sender identification of the service party S is queried in the zookeeper.
跨语言调用程序10根据查询到的服务信息创建一个与上述接口类对应的 代理类。其中,服务方3接口下若有多台主机提供服务,对应的代理类也有多个invoker实体与多个主机关联。例如,跨语言调用程序根据服务信息,自动重写dubbo初始化流程,创建一个与接口类对应的动态代理类。使得代理类与接口类进行绑定。The cross-language caller 10 creates a proxy class corresponding to the above interface class based on the queried service information. Wherein, if there are multiple hosts providing services under the servant 3 interface, the corresponding proxy class also has multiple invoker entities associated with multiple hosts. For example, the cross-language caller automatically rewrites the dubbo initialization process based on the service information to create a dynamic proxy class corresponding to the interface class. Bind the proxy class to the interface class.
跨语言调用程序10根据创建的代理类生成唯一的URL。其中,URL的生成规则是根据每一个方法名自动生产一个唯一的URL地址。并将唯一的URL地址与对应的接口类进行绑定。其中URL是web页的地址,主要由两个主要的部分构成:协议和目的地。其中协议包括http、ftp、telnet等,目的地可以是某文件名、目录名或者某台计算机的名称。例如,跨语言调用程序将代理类生成的唯一的URL地址与虚拟机上的接口类进行绑定,使得请求方A在搜索服务时,能够找到服务方S。The cross-language caller 10 generates a unique URL based on the created proxy class. Among them, the URL generation rule is to automatically generate a unique URL address according to each method name. Bind the unique URL address to the corresponding interface class. The URL is the address of the web page and consists of two main parts: the protocol and the destination. The agreement includes http, ftp, telnet, etc. The destination can be a file name, a directory name, or the name of a computer. For example, the cross-language caller binds the unique URL address generated by the proxy class to the interface class on the virtual machine so that requester A can find the servant S when searching for the service.
当请求方4需要申请服务时,请求方4向跨语言调用程序10发送http协议格式的服务调用请求,跨语言调用程序10接收请求方4发出的http协议格式的服务调用请求。其中,服务调用请求由请求方法URI协议/版本、请求头、请求正文三部分组成。例如,请求方A向基于dubbo平台发送http协议格式的声纹识别服务调用请求。When the requesting party 4 needs to apply for a service, the requesting party 4 sends a service invocation request in the http protocol format to the cross-language invoking program 10, and the cross-language invoking program 10 receives the service invoking request in the http protocol format issued by the requesting party 4. The service invocation request is composed of a request method URI protocol/version, a request header, and a request body. For example, the requester A sends a voiceprint recognition service call request to the dubbo platform based on the http protocol format.
跨语言调用程序10将服务调用请求从http协议格式转换为hessian协议格式。其中,跨语言调用程序10与服务方3预先确定服务调用请求的二进制编解码规范,hessian通过预先确定的二进制编解码规范将服务调用请求进行二进制编码,产生二进制码流。根据产生的二进制码流读取服务调用请求中的URL地址。其中,hessian协议是开源、通用协议,在服务器和服务方3实现hessian协议的情况下,请求方4可以java、C++、python、ruby等多种语言对服务方3进行服务调用。例如,跨语言调用程序将请求方A的声纹识别服务调用请求从http协议格式转换为hessian协议格式,生成二进制码流。The cross-language caller 10 converts the service call request from the http protocol format to the hessian protocol format. The cross-language caller 10 and the servant 3 predetermine the binary codec specification of the service call request, and the hessian binary-encodes the service call request through a predetermined binary codec specification to generate a binary code stream. The URL address in the service call request is read according to the generated binary stream. Among them, the hessian protocol is an open source, general-purpose protocol. In the case that the server and the server 3 implement the hessian protocol, the requesting party 4 can make service calls to the service party 3 in various languages such as java, C++, python, ruby, and the like. For example, the cross-language caller converts the voiceprint recognition service invocation request of requester A from the http protocol format to the hessian protocol format to generate a binary code stream.
跨语言调用程序10根据服务调用请求中的URL地址找到对应的接口类,再根据接口类与代理类的对应关系从代理类中找到相对应的invoker实体。例如,跨语言调用程序根据声纹识别服务调用请求中的URL地址找到对应的代理类,再根据接口类与代理类的对应关系从接口类中找到相对应的invoker实体。The cross-language invoking program 10 finds the corresponding interface class according to the URL address in the service invocation request, and then finds the corresponding invoker entity from the proxy class according to the correspondence between the interface class and the proxy class. For example, the cross-language calling program finds the corresponding proxy class according to the URL address in the voiceprint recognition service call request, and then finds the corresponding invoker entity from the interface class according to the correspondence between the interface class and the proxy class.
该invoker实体将hessian协议格式的服务调用请求的二进制码流发送给 服务方3与该invoker实体相对应的主机,服务方3根据预先确定的二进制编解码规范对服务调用请求的二进制码流进行解码,读取出请求方4的服务调用请求,发起服务调用。例如,服务方S的声纹识别主机接收到invoker实体发送的hessian协议格式的声纹识别服务调用请求后,利用预先确定的二进制编解码规范对hessian协议格式的二进制码流进行解码,发起声纹识别服务调用。The invoker entity sends a binary code stream of the service call request in the hessian protocol format to the host corresponding to the invoker entity, and the server 3 decodes the binary code stream requested by the service call according to a predetermined binary codec specification. , read out the service call request of the requester 4, initiate a service call. For example, after receiving the voiceprint recognition service call request of the hessian protocol format sent by the invoker entity, the voiceprint recognition host of the service party S decodes the binary code stream of the hessian protocol format by using a predetermined binary codec specification, and initiates a voiceprint. Identify service calls.
上述实施例提出的跨语言调用方法,通过将服务页面接收的主机集群IP地址和端口地址写入注册中心,根据接收的接口信息创建接口类并加载到虚拟机内存上,然后根据接口信息查询服务信息并创建代理类生成唯一的URL,最后将接收到服务调用请求的http协议格式转换为hessian协议格式,并找到对应的invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,使得基于dubbo平台能够兼容java、C++、python、ruby等语言进行调用,扩大服务调用范围。The cross-language calling method in the foregoing embodiment writes the host cluster IP address and port address received by the service page into the registration center, creates an interface class according to the received interface information, loads the virtual machine into the virtual machine memory, and then queries the service according to the interface information. Information and create a proxy class to generate a unique URL, and finally convert the http protocol format that receives the service call request into a hessian protocol format, and find the corresponding invoker entity to send the service call request in the hessian protocol format to the corresponding host of the service party, so that Based on the dubbo platform, it can be compatible with Java, C++, Python, ruby and other languages to expand the scope of service calls.
此外,本申请实施例还提出一种计算机可读存储介质,所述计算机可读存储介质中包括跨语言调用程序10,所述跨语言调用程序10被处理器执行时实现如下操作:In addition, the embodiment of the present application further provides a computer readable storage medium, where the computer readable storage medium includes a cross-language calling program 10, and when the cross-language calling program 10 is executed by the processor, the following operations are implemented:
接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心;Receiving the interface information of the servant, the host cluster IP address and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
根据所述接口信息创建一个接口类,保存到存储器;Creating an interface class according to the interface information, and saving to the memory;
调用类加载器将接口类从存储器加载到内存;Calling the class loader to load the interface class from memory into memory;
根据所述接口信息从注册中心查询服务方提供的服务信息;Querying, according to the interface information, the service information provided by the service party from the registration center;
根据查询到的服务信息创建一个与上述接口类对应的代理类;Creating a proxy class corresponding to the above interface class according to the service information that is queried;
根据代理类生成唯一的URL;Generate a unique URL based on the proxy class;
接收请求方发出的http协议格式的服务调用请求;Receiving a service call request in the http protocol format issued by the requesting party;
将服务调用请求从http协议格式转换为hessian协议格式;Convert the service invocation request from the http protocol format to the hessian protocol format;
根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;Find the corresponding proxy class according to the URL address in the call request, and find the corresponding invoker entity according to the correspondence between the proxy class and the interface class;
由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
优选地,所述接口类定义了接口包名、接口类名、接口类中方法名、请求参数及返回函数。Preferably, the interface class defines an interface package name, an interface class name, a method name in the interface class, a request parameter, and a return function.
优选地,所述服务方通过注册中心发布服务信息,并获得接口信息。Preferably, the service party issues service information through the registration center and obtains interface information.
优选地,所述服务方若有多台主机提供服务,则所述代理类也包括多个invoker实体与所述多台主机相关联。Preferably, if the servant has multiple hosts providing services, the proxy class also includes a plurality of invoker entities associated with the plurality of hosts.
优选地,所述URL的生成规则是根据每一个方法名自动生产一个唯一的URL地址。Preferably, the URL generation rule is to automatically generate a unique URL address according to each method name.
本申请之计算机可读存储介质的具体实施方式与上述跨语言调用方法的具体实施方式大致相同,在此不再赘述。The specific implementation manner of the computer readable storage medium of the present application is substantially the same as the specific implementation manner of the above-mentioned cross-language calling method, and details are not described herein again.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present application are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better. Implementation. Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM as described above). , a disk, an optical disk, including a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the methods described in the various embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其它相关的技术领域,均同理包括在本申请的专利保护范围内。The above is only a preferred embodiment of the present application, and thus does not limit the scope of the patent application, and the equivalent structure or equivalent process transformation made by the specification and the drawings of the present application, or directly or indirectly applied to other related technical fields. The same is included in the scope of patent protection of this application.

Claims (20)

  1. 一种跨语言调用方法,其特征在于,所述方法包括:A cross-language calling method, the method comprising:
    接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心;Receiving the interface information of the servant, the host cluster IP address and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
    根据所述接口信息创建一个接口类,保存到存储器;Creating an interface class according to the interface information, and saving to the memory;
    调用类加载器将接口类从存储器加载到内存;Calling the class loader to load the interface class from memory into memory;
    根据所述接口信息从注册中心查询服务方提供的服务信息;Querying, according to the interface information, the service information provided by the service party from the registration center;
    根据查询到的服务信息创建一个与上述接口类对应的代理类;Creating a proxy class corresponding to the above interface class according to the service information that is queried;
    根据代理类生成唯一的URL;Generate a unique URL based on the proxy class;
    接收请求方发出的http协议格式的服务调用请求;Receiving a service call request in the http protocol format issued by the requesting party;
    将服务调用请求从http协议格式转换为hessian协议格式;Convert the service invocation request from the http protocol format to the hessian protocol format;
    根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;Find the corresponding proxy class according to the URL address in the call request, and find the corresponding invoker entity according to the correspondence between the proxy class and the interface class;
    由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
  2. 根据权利要求1所述的跨语言调用方法,其特征在于,所述接口类定义了接口包名、接口类名、接口类中方法名、请求参数及返回函数。The cross-language calling method according to claim 1, wherein the interface class defines an interface package name, an interface class name, a method name in the interface class, a request parameter, and a return function.
  3. 根据权利要求2所述的跨语言调用方法,其特征在于,所述接口类存储于本地存储器,使用时,调用类加载器将接口类加载到虚拟机内存。The cross-language calling method according to claim 2, wherein the interface class is stored in a local memory, and in use, the calling class loader loads the interface class into the virtual machine memory.
  4. 根据权利要求1所述的跨语言调用方法,其特征在于,所述服务方通过注册中心发布服务信息,并获得接口信息。The cross-language calling method according to claim 1, wherein the service party issues service information through the registration center and obtains interface information.
  5. 根据权利要求1所述的跨语言调用方法,其特征在于,所述服务方若有多台主机提供服务,则所述代理类也包括多个invoker实体与所述多台主机相关联。The cross-language calling method according to claim 1, wherein if the servant has a plurality of hosts providing services, the proxy class also includes a plurality of invoker entities associated with the plurality of hosts.
  6. 根据权利要求1所述的跨语言调用方法,其特征在于,所述URL的生成规则是根据每一个方法名自动生产一个唯一的URL地址。The cross-language calling method according to claim 1, wherein the URL generation rule automatically generates a unique URL address according to each method name.
  7. 根据权利要求6所述的跨语言调用方法,其特征在于,所述URL地址由协议和目的地构成。The cross-language calling method according to claim 6, wherein the URL address is composed of a protocol and a destination.
  8. 一种服务器,其特征在于,所述服务器包括:存储器、处理器,所述存储器上存储有跨语言调用程序,所述跨语言调用程序被所述处理器执行, 可实现如下步骤:A server, comprising: a memory, a processor, wherein the memory stores a cross-language calling program, and the cross-language calling program is executed by the processor, and the following steps can be implemented:
    接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集群IP地址和端口地址写入注册中心;Receiving the interface information of the servant, the host cluster IP address and the port address, and writing the host cluster IP address and port address of the servant to the registration center;
    根据所述接口信息创建一个接口类,保存到存储器;Creating an interface class according to the interface information, and saving to the memory;
    调用类加载器将接口类从存储器加载到内存;Calling the class loader to load the interface class from memory into memory;
    根据所述接口信息从注册中心查询服务方提供的服务信息;Querying, according to the interface information, the service information provided by the service party from the registration center;
    根据查询到的服务信息创建一个与上述接口类对应的代理类;Creating a proxy class corresponding to the above interface class according to the service information that is queried;
    根据代理类生成唯一的URL;Generate a unique URL based on the proxy class;
    接收请求方发出的http协议格式的服务调用请求;Receiving a service call request in the http protocol format issued by the requesting party;
    将服务调用请求从http协议格式转换为hessian协议格式;Convert the service invocation request from the http protocol format to the hessian protocol format;
    根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;Find the corresponding proxy class according to the URL address in the call request, and find the corresponding invoker entity according to the correspondence between the proxy class and the interface class;
    由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
  9. 根据权利要求8所述的服务器,其特征在于,所述接口类定义了接口包名、接口类名、接口类中方法名、请求参数及返回函数。The server according to claim 8, wherein the interface class defines an interface package name, an interface class name, a method name in the interface class, a request parameter, and a return function.
  10. 根据权利要求9所述的服务器,其特征在于,所述接口类存储于本地存储器,使用时,调用类加载器将接口类加载到虚拟机内存。The server according to claim 9, wherein the interface class is stored in a local memory, and in use, the class loader is called to load the interface class into the virtual machine memory.
  11. 根据权利要求8所述的服务器,其特征在于,所述服务方通过注册中心发布服务信息,并获得接口信息。The server according to claim 8, wherein the service party issues service information through the registration center and obtains interface information.
  12. 根据权利要求8所述的服务器,其特征在于,所述服务方若有多台主机提供服务,则所述代理类也包括多个invoker实体与所述多台主机相关联。The server according to claim 8, wherein if the server has multiple hosts providing services, the agent class also includes a plurality of invoker entities associated with the plurality of hosts.
  13. 根据权利要求8所述的服务器,其特征在于,所述URL的生成规则是根据每一个方法名自动生产一个唯一的URL地址。The server according to claim 8, wherein said URL generation rule is to automatically generate a unique URL address based on each method name.
  14. 根据权利要求13所述的服务器,其特征在于,所述URL地址由协议和目的地构成。The server according to claim 13, wherein said URL address is composed of a protocol and a destination.
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中包括跨语言调用程序,所述统跨语言调用程序被处理器执行时,可实现如下步骤:A computer readable storage medium, wherein the computer readable storage medium includes a cross-language calling program, and when the system cross-language calling program is executed by a processor, the following steps can be implemented:
    接收服务方的接口信息、主机集群IP地址和端口地址,将服务方的主机集 群IP地址和端口地址写入注册中心;Receiving the interface information of the servant, the host cluster IP address and the port address, and writing the host group IP address and port address of the servant to the registration center;
    根据所述接口信息创建一个接口类,保存到存储器;Creating an interface class according to the interface information, and saving to the memory;
    调用类加载器将接口类从存储器加载到内存;Calling the class loader to load the interface class from memory into memory;
    根据所述接口信息从注册中心查询服务方提供的服务信息;Querying, according to the interface information, the service information provided by the service party from the registration center;
    根据查询到的服务信息创建一个与上述接口类对应的代理类;Creating a proxy class corresponding to the above interface class according to the service information that is queried;
    根据代理类生成唯一的URL;Generate a unique URL based on the proxy class;
    接收请求方发出的http协议格式的服务调用请求;Receiving a service call request in the http protocol format issued by the requesting party;
    将服务调用请求从http协议格式转换为hessian协议格式;Convert the service invocation request from the http protocol format to the hessian protocol format;
    根据调用请求中的URL地址找到对应的代理类,根据代理类与接口类的对应关系找到相应的invoker实体;Find the corresponding proxy class according to the URL address in the call request, and find the corresponding invoker entity according to the correspondence between the proxy class and the interface class;
    由该invoker实体将hessian协议格式的服务调用请求发送给服务方的相应主机,发起服务访问请求。The service call request of the hessian protocol format is sent by the invoker entity to the corresponding host of the service party to initiate a service access request.
  16. 根据权利要求15所述的计算机可读存储介质,其特征在于,所述接口类定义了接口包名、接口类名、接口类中方法名、请求参数及返回函数。The computer readable storage medium of claim 15, wherein the interface class defines an interface package name, an interface class name, a method name in the interface class, a request parameter, and a return function.
  17. 根据权利要求16所述的计算机可读存储介质,其特征在于,所述接口类存储于本地存储器,使用时,调用类加载器将接口类加载到虚拟机内存。The computer readable storage medium of claim 16, wherein the interface class is stored in a local memory, and in use, the class loader is called to load the interface class into the virtual machine memory.
  18. 根据权利要求15所述的计算机可读存储介质,其特征在于,所述服务方通过注册中心发布服务信息,并获得接口信息。A computer readable storage medium according to claim 15, wherein said service party issues service information through a registration center and obtains interface information.
  19. 根据权利要求15所述的计算机可读存储介质,其特征在于,所述服务方若有多台主机提供服务,则所述代理类也包括多个invoker实体与所述多台主机相关联。The computer readable storage medium according to claim 15, wherein if the servant has a plurality of hosts providing services, the proxy class also includes a plurality of invoker entities associated with the plurality of hosts.
  20. 根据权利要求15所述的计算机可读存储介质,其特征在于,所述URL的生成规则是根据每一个方法名自动生产一个唯一的URL地址。The computer readable storage medium according to claim 15, wherein said URL generation rule is to automatically generate a unique URL address based on each method name.
PCT/CN2018/089135 2017-11-30 2018-05-31 Cross-language invoking method, server, and storage medium WO2019104973A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711239546.2A CN108255615B (en) 2017-11-30 2017-11-30 Cross-language calling method, server and storage medium
CN201711239546.2 2017-11-30

Publications (1)

Publication Number Publication Date
WO2019104973A1 true WO2019104973A1 (en) 2019-06-06

Family

ID=62722078

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/089135 WO2019104973A1 (en) 2017-11-30 2018-05-31 Cross-language invoking method, server, and storage medium

Country Status (2)

Country Link
CN (1) CN108255615B (en)
WO (1) WO2019104973A1 (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110855782A (en) * 2019-11-14 2020-02-28 北京顺丰同城科技有限公司 Service calling system, method, electronic equipment and readable storage medium
CN111741118A (en) * 2020-06-28 2020-10-02 中国平安财产保险股份有限公司 Interface calling method and device, computer equipment and computer readable storage medium
CN112035276A (en) * 2020-08-06 2020-12-04 上海视云网络科技有限公司 Java-based cross-platform extensible Remote Procedure Call (RPC) framework design method
CN112114979A (en) * 2020-08-31 2020-12-22 厦门安胜网络科技有限公司 Remote procedure call method and device
CN112256246A (en) * 2020-09-18 2021-01-22 许继集团有限公司 Micro-service integration framework for supporting cross-language calling in power system
CN112579212A (en) * 2019-09-29 2021-03-30 北京国双科技有限公司 Cross-language calling method, calling party device and called party device
CN112612460A (en) * 2020-12-28 2021-04-06 北京锐安科技有限公司 Interface packaging and calling method, electronic device and storage medium
CN113590231A (en) * 2021-08-17 2021-11-02 上海微盟企业发展有限公司 Component loading method, system, device and storage medium
CN113821352A (en) * 2021-02-02 2021-12-21 北京沃东天骏信息技术有限公司 Remote service calling method and device
CN114900383A (en) * 2022-03-28 2022-08-12 青岛海尔科技有限公司 Interface processing method and device, electronic equipment and computer readable storage medium
CN117270833A (en) * 2023-11-21 2023-12-22 支付宝(杭州)信息技术有限公司 Service calling and issuing method, medium and computer equipment

Families Citing this family (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109298954B (en) * 2018-09-14 2019-10-25 北京数聚鑫云信息技术有限公司 A kind of intelligence calls the method and device of Dubbo remote service
CN109151091B (en) * 2018-09-21 2022-01-21 福建南威软件有限公司 API gateway service supporting dubbo protocol calling
CN109150904A (en) * 2018-09-25 2019-01-04 深圳市佰仟金融服务有限公司 Interface service call method and terminal device
CN109922148B (en) * 2019-03-04 2022-02-25 网易(杭州)网络有限公司 Cross-platform service method, device and system
CN111782413B (en) * 2019-04-04 2024-02-27 杭州海康威视系统技术有限公司 Cross-application component communication method and device
CN110032458B (en) * 2019-04-12 2020-07-10 重庆天蓬网络有限公司 PHP cross-language unified calling system
CN110191164B (en) * 2019-05-20 2022-03-22 中国工商银行股份有限公司 Distributed service access system and method
CN111176626B (en) * 2019-08-05 2022-04-19 腾讯科技(深圳)有限公司 Cross-programming-language code calling method and device, medium and equipment
CN112422309B (en) * 2019-08-23 2023-03-28 阿里巴巴集团控股有限公司 System and method for distributed service discovery, storage medium and terminal
CN110659017B (en) * 2019-09-19 2024-03-29 上海客佳信息科技有限公司 External request processing method and related device
CN110647411A (en) * 2019-10-10 2020-01-03 广州趣丸网络科技有限公司 Service request processing method and device
CN110708319A (en) * 2019-10-10 2020-01-17 广州趣丸网络科技有限公司 Service request processing method and device
CN111209122B (en) * 2019-12-24 2024-06-11 广州华多网络科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN111212119B (en) * 2019-12-24 2023-09-01 国电南瑞科技股份有限公司 Dubbo service calling method and system
CN111625243B (en) * 2020-05-13 2023-07-18 北京字节跳动网络技术有限公司 Cross-language task processing method and device and electronic equipment
CN111917838B (en) * 2020-07-14 2023-08-29 浙江大华技术股份有限公司 Micro-service-based processing method and device, storage medium and electronic device
CN112199219A (en) * 2020-11-17 2021-01-08 南开大学 Cross-language operation remote calling method
CN112804303B (en) * 2020-12-31 2023-11-03 网银在线(北京)科技有限公司 Service providing method, device, system, transit platform and storage medium
CN114721842A (en) * 2021-01-05 2022-07-08 中国移动通信有限公司研究院 Service calling method and device and electronic equipment
CN112905470A (en) * 2021-02-23 2021-06-04 中国平安人寿保险股份有限公司 Interface calling method and device, computer equipment and medium
CN113127081B (en) * 2021-04-19 2023-09-15 浪潮金融信息技术有限公司 Lightweight interactive method, system and medium for terminal
CN113242221B (en) * 2021-04-29 2022-08-23 湖南快乐阳光互动娱乐传媒有限公司 Protocol conversion method and protocol conversion device based on http micro-service gateway
CN113448689A (en) * 2021-07-09 2021-09-28 中国银行股份有限公司 Dubbo protocol conversion device and method in operation period

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002024120A (en) * 2000-07-11 2002-01-25 Mitsubishi Electric Corp Distributed application server system
CN103283209A (en) * 2011-04-18 2013-09-04 北京新媒传信科技有限公司 Application service platform system and implementation method thereof
CN105450757A (en) * 2015-12-02 2016-03-30 联动优势电子商务有限公司 Service management method and system
CN106411933A (en) * 2016-11-15 2017-02-15 深圳市彬讯科技有限公司 Lightweight RPC framework capable of service management and language calling

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB201108709D0 (en) * 2011-05-24 2011-07-06 Corethree Ltd Core engine
CN103136095A (en) * 2011-11-28 2013-06-05 阿里巴巴集团控股有限公司 Method, device and system of test application program interface
CN103425462B (en) * 2012-05-14 2016-12-14 阿里巴巴集团控股有限公司 A kind of method and apparatus of workflow data persistence
CN105450589B (en) * 2014-07-31 2018-12-14 阿里巴巴集团控股有限公司 Remote invocation method and system
CN104270470A (en) * 2014-10-24 2015-01-07 杭州高达软件系统股份有限公司 Remote service invocation method, device and system
US9699249B2 (en) * 2014-12-05 2017-07-04 Vmware, Inc. Runtime generation of application programming interfaces for remote procedure call services
CN106506509B (en) * 2016-11-15 2019-11-08 深圳市彬讯科技有限公司 It can carry out the lightweight RPC framework implementation method of service improvement and language call
CN107301098B (en) * 2017-06-15 2020-09-08 搜易贷(北京)金融信息服务有限公司 Remote procedure calling device, method and system based on Thrift protocol

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002024120A (en) * 2000-07-11 2002-01-25 Mitsubishi Electric Corp Distributed application server system
CN103283209A (en) * 2011-04-18 2013-09-04 北京新媒传信科技有限公司 Application service platform system and implementation method thereof
CN105450757A (en) * 2015-12-02 2016-03-30 联动优势电子商务有限公司 Service management method and system
CN106411933A (en) * 2016-11-15 2017-02-15 深圳市彬讯科技有限公司 Lightweight RPC framework capable of service management and language calling

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112579212A (en) * 2019-09-29 2021-03-30 北京国双科技有限公司 Cross-language calling method, calling party device and called party device
CN110855782B (en) * 2019-11-14 2022-12-02 北京顺丰同城科技有限公司 Service calling system, method, electronic equipment and readable storage medium
CN110855782A (en) * 2019-11-14 2020-02-28 北京顺丰同城科技有限公司 Service calling system, method, electronic equipment and readable storage medium
CN111741118A (en) * 2020-06-28 2020-10-02 中国平安财产保险股份有限公司 Interface calling method and device, computer equipment and computer readable storage medium
CN111741118B (en) * 2020-06-28 2023-06-02 中国平安财产保险股份有限公司 Interface calling method, device, computer equipment and computer readable storage medium
CN112035276A (en) * 2020-08-06 2020-12-04 上海视云网络科技有限公司 Java-based cross-platform extensible Remote Procedure Call (RPC) framework design method
CN112114979A (en) * 2020-08-31 2020-12-22 厦门安胜网络科技有限公司 Remote procedure call method and device
CN112114979B (en) * 2020-08-31 2024-03-19 厦门安胜网络科技有限公司 Remote procedure call method and device
CN112256246A (en) * 2020-09-18 2021-01-22 许继集团有限公司 Micro-service integration framework for supporting cross-language calling in power system
CN112612460A (en) * 2020-12-28 2021-04-06 北京锐安科技有限公司 Interface packaging and calling method, electronic device and storage medium
CN113821352A (en) * 2021-02-02 2021-12-21 北京沃东天骏信息技术有限公司 Remote service calling method and device
CN113590231A (en) * 2021-08-17 2021-11-02 上海微盟企业发展有限公司 Component loading method, system, device and storage medium
CN113590231B (en) * 2021-08-17 2024-05-10 上海微盟企业发展有限公司 Component loading method, system, device and storage medium
CN114900383A (en) * 2022-03-28 2022-08-12 青岛海尔科技有限公司 Interface processing method and device, electronic equipment and computer readable storage medium
CN114900383B (en) * 2022-03-28 2024-04-19 青岛海尔科技有限公司 Interface processing method, device, electronic equipment and computer readable storage medium
CN117270833A (en) * 2023-11-21 2023-12-22 支付宝(杭州)信息技术有限公司 Service calling and issuing method, medium and computer equipment
CN117270833B (en) * 2023-11-21 2024-04-26 支付宝(杭州)信息技术有限公司 Service calling and issuing method, medium and computer equipment

Also Published As

Publication number Publication date
CN108255615B (en) 2022-03-01
CN108255615A (en) 2018-07-06

Similar Documents

Publication Publication Date Title
WO2019104973A1 (en) Cross-language invoking method, server, and storage medium
CN108055248B (en) Dubbo framework-based remote calling method, server and storage medium
US10623476B2 (en) Endpoint management system providing an application programming interface proxy service
US10956652B2 (en) Support for non-native file types in web application environment
WO2016192556A1 (en) Interface invoking method, device and terminal
CN112114979B (en) Remote procedure call method and device
WO2018184535A1 (en) Insurance service processing method and device, server, and storage medium
CN111045833B (en) Interface calling method and device
CN111698205B (en) Service calling method and related equipment
JP2005251171A (en) Information provision device, information provision method, information provision program and recording medium
CN114281263B (en) Storage resource processing method, system and equipment of container cluster management system
CN113448756B (en) Inter-process communication system and method and computing device
CN112507005A (en) Method and device for processing message
CN110704200A (en) Method and device for converting call interface
US8495664B2 (en) System, method and program product for invoking a remote method
WO2019136813A1 (en) Api file management method, server, and storage medium
US11379201B2 (en) Wrapping method, registration method, device, and rendering apparatus
CN109618016B (en) DNS request sending and processing method, related method and related device
US7792921B2 (en) Metadata endpoint for a generic service
CN113760318A (en) Information processing method, information processing apparatus, server, and storage medium
CN116795913A (en) Data export method, data import method and data export import system
CN110888901B (en) System management method, device, computer equipment and storage medium
CN113779122A (en) Method and apparatus for exporting data
US8874752B2 (en) Provision of other than 1:1 resource mapping
US11178215B1 (en) Transparent support and translation for client-provided identifiers in service requests

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18882797

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 09.09.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18882797

Country of ref document: EP

Kind code of ref document: A1