def SaveDict(savedict,dataid): dataid=dataid ## if savedict['req'][0]['RequestType']== "string" : print r"API请求参数类型为"+savedict['req'][0]['RequestType'] dictlist=savedict['req'] urldata=dictlist[2]['parm'] service_get= dictlist[1]['url'].split('.',2) print urldata tcp_url=fronturl+service_get[0] print tcp_url service = HessianProxy(tcp_url) service.method= service_get[2] resplog="resplog=service."+service_get[1]+"(long(urldata[1]),urldata[0])."+service_get[2] print resplog exec(resplog) print resplog savelog(txtfile,dataid,urldata,resplog) elif savedict['req'][0]['RequestType']== "json" : print r"API请求参数类型为"+savedict['req'][0]['RequestType'] dictlist=savedict['req'] urldata=dictlist[2]['parm'] service_get= dictlist[1]['url'].split('.',2) print urldata tcp_url=fronturl+service_get[0] print tcp_url service = HessianProxy(tcp_url) service.method= service_get[1] resplog="resplog=service."+service_get[1]+"(urldata)."+service_get[2] print resplog exec(resplog) print resplog savelog(txtfile,dataid,urldata,resplog) elif savedict['req'][0]['RequestType']== "mix" : print r"API请求参数类型为"+savedict['req'][0]['RequestType'] dictlist=savedict['req'] urldata=dictlist[2]['parm'] service_get= dictlist[1]['url'].split('.',2) print urldata tcp_url=fronturl+service_get[0] print tcp_url service = HessianProxy(tcp_url) service.method= service_get[1] resplog="resplog=service."+service_get[1]+"(urldata[0],urldata[1],urldata[2],urldata[3],urldata[4])."+service_get[2] exec(resplog) print resplog savelog(txtfile,dataid,urldata,resplog)
def real_fun(self, *args, **kwargs): uri = self.locator.locate(tx) service = HessianProxy(uri, timeout=self.timeout) res = service.invoke(Object('net.butfly.bus.Request', tx=tx, version=version, args=args, extParamMap=kwargs)) if res.errorCode is not None: raise AlbusError(res.errorCode, res.errorMessage, res.errorStack) return res.resultCode, res.result
def test_login(self): from mustaine.client import HessianProxy service = HessianProxy(self.hessian_proxy) device_info_dto = { 'clientType': 1, 'clientVer': '1.0', 'deviceName': 'LaoDuan\'s iphone', 'deviceId': 'xxx001', 'lastLat': 0.00, 'lastLng': 0.00, 'relativeId1': 'channel', 'relativeId2': 'user_id' } try: service.sellerLogin(None, self.phone_number, "000000", device_info_dto) except Exception, ex: print('Input: ' + self.phone_number + 'Error:' + ex.message)
#!/usr/bin/python # coding=utf-8 from mustaine.client import HessianProxy """ 参考文档:http://blog.csdn.net/haizhaopeng/article/details/47104897 我们只需要知道提供服务暴露的URL和服务接口即可,这里URL为http://10.95.3.74:8080/http_dubbo/search, 接口为org.shirdrn.platform.dubbo.service.rpc.api.SolrSearchService。 运行程序,可以调用提供方发布的服务。 """ serviceUrl = 'http://10.95.3.74:8080/http_dubbo/search' q = 'q=*:*&fl=*&fq=building_type:1' start = 0 rows = 10 resType = 'xml' collection = 'tinycollection' if __name__ == '__main__': proxy = HessianProxy(serviceUrl) result = proxy.search(collection, q, resType, start, rows) print result
# -*- coding: utf-8 -*- from mustaine.client import HessianProxy import urllib2 import json proxy = HessianProxy('http://webservice.build.index.com:9011/webservice/3gcms') class DocFetcher: def fetchDoc(self, channelid, ftime, ttime, offset, size): return proxy.get3GArticles(channelid, ftime, ttime, offset, size) def getDocByTopic(self, topicid, offset, size): docs = proxy.getTopicArticle(topicid, offset, size) for doc in docs: print 'id len: %d' % len(doc['docid']) doc['body'] = self.getBody(doc['docid']) print 'body len: %d, topicid: %s' % (len( doc['body']), doc['topicid']) return docs def getBody(self, docid): url = 'http://c.3g.163.com/nc/article/%s/full.html' % docid response = urllib2.urlopen(url) docInfo = response.read() docJson = json.loads(docInfo) if docJson[docid].has_key('body'): return docJson[docid]['body'] else:
import pymongo from mustaine.client import HessianProxy import mustaine from pymongo import Connection PAGESIZE = 500 connection = Connection() db = connection.vocab value_set_concepts = db.valueSetConcepts service = HessianProxy("http://phinvads.cdc.gov/vocabService/v2") def toBSON(o): ret = {} for k in dir(o): if k.startswith("_"): continue v = getattr(o, k) if type(v) == list: ret[k] = map(toBSON, v) elif type(v) == mustaine.protocol.Object: ret[k] = toBSON(v) else: ret[k] = v return ret codeSystems = {} for cs in db.codeSystems.find({}): codeSystems[cs['oid']] = cs
from mustaine import protocol from mustaine.client import HessianProxy # Caucho's Hessian 2.0 reference service # interface: http://caucho.com/resin-javadoc/com/caucho/hessian/test/TestHessian2.html test = HessianProxy("http://hessian.caucho.com/test/test") ### BINARY ENCODING TESTS DISABLED # def test_encode_binary_0(): # assert test.argBinary_0(protocol.Binary("")) is True # # def test_encode_binary_1(): # assert test.argBinary_1(protocol.Binary("x")) is True # # def test_encode_binary_1023(): # assert test.argBinary_1023(protocol.Binary("x" * 1023)) is True # # def test_encode_binary_1024(): # assert test.argBinary_1024(protocol.Binary("x" * 1024)) is True # # def test_encode_binary_15(): # assert test.argBinary_15(protocol.Binary("x" * 15)) is True # # def test_encode_binary_16(): # assert test.argBinary_16(protocol.Binary("x" * 16)) is True # # def test_encode_binary_65536(): # assert test.argBinary_65536(protocol.Binary("x" * 65536)) is True ### DATE ENCODING TESTS DISABLED, UTC MADNESS