About the Dubbo Hession protocol:
Dubbo itself supports a variety of remote invocation methods, such as Dubbo RPC (binary serialization + TCP protocol), HTTP invoker (binary serialization + HTTP protocol), Hessian (binary serialization + HTTP protocol), WebServices (text serialization + HTTP protocol) and so on.
Dubbo the implementation of these protocols is encapsulated, whether the server (development services) or the client (invoke the service), do not need to care about the details of the protocol, only in the configuration to specify the use of the Protocol to ensure that the service provider and service consumers between the transparency.
If we use the Dubbo Service registry component, so that the service provider publishes the service to the registered center, only exposes the name of the service to the outside, and the service consumer only needs to know the name of the service provided by the Registry and the service provider to invoke the service transparently.
Python calls the Hession protocol interface with the following basic process:
1. Download and install the Python Hessian Library, address: Https://github.com/theatlantic/python-hessian
2. Define the service, interface, method name of the Hession interface
3. Using the Protocol.object_factory method, call the method parameter construction method, construct the call parameter
4. Using the Hessianproxy method, call the interface
Sample code:
#-*-Coding:utf-8-*-
From pyhessian.client import Hessianproxy
From Pyhessian Import Protocol
Import JSON
Def invokehessian (service,interface,method,req,retcode= ' 000000 '):
try:
url= ' http://192.168.0.1:10883/' +service+ '. +interface
Print url:\t%s '%url
print ' method:\t%s '%method
print ' req:\t%s '%req
res=getattr ( Hessianproxy (URL), method) (req)
print ' res:\t%s '%json.dumps Res, Ensure_ascii=false)
except exception,e:
print e
if __name__ = = ' __main__ ':
Service= ' Com.service.common.api.service '
Interface= ' Testhessianservice '
Method= ' Testhessian '
Req=protocol.object_factory (' Com.service.common.api.service.model.req.TestHessianRequest ',
Param1= ' Lovesoo ', param2=10086)
Invokehessian (Service, interface, Method,req)
Attached, official example demo:https://github.com/theatlantic/python-hessian/blob/master/tests/test_parser.py