python编写简单程序访问A8系统

来源:互联网 发布:ubuntu安装空闲不可用 编辑:程序博客网 时间:2024/05/29 03:48

1,安装suds库,用于方便的调用WebServices。

2,以用户名和密码访问A8的验证服务获取token。此token有效期为15分钟分钟,每一次有效请求延长 10分钟, 最长 15分钟。

3,以token访问所需服务。以BPMService(业务单据流程集成服务)为例,提供以下方法:

getAllFormCollIdsByDateTime(xs:string token, xs:string beginDateTime, xs:string endDateTime, )getAllFormCollIdsByDateTimeAndState(xs:string token, xs:string beginDateTime, xs:string endDateTime, xs:int[] state, )getFlowState(xs:string token, xs:long flowId, )getFormApprovalState(xs:string token, xs:long id, )getFormCollIdsByDateTime(xs:string token, xs:string[] templateCode, xs:string beginDateTime, xs:string endDateTime, )getTemplateDefinition(xs:string token, xs:string templateCode, )launchFormCollaboration(xs:string token, xs:string senderLoginName, xs:string templateCode, xs:string subject,                         xs:string data, xs:long[] attachments, xs:string param, )launchHtmlCollaboration(xs:string token, xs:string senderLoginName, xs:string templateCode, xs:string subject,                         xs:string bodyContent, xs:long[] attachments, )sendFormCollaboration(xs:string token, xs:string senderLoginName, xs:string templateCode, xs:string subject,                       xs:string data, xs:string attachments, xs:string param, )

具体操作如下:

#!usr/bin/env python#coding: utf-8from suds.client import Client'''验证服务    authenticate(xs:string userName, xs:string password, )'''authority_url = 'http://{host}:{port}/seeyon/services/authorityService?wsdl'  # host和port换成部署A8系统的client = Client(authority_url)token = client.service.authenticate('admin', 'passwd')  # 获取令牌print token'''连接BPMservice'''form_url = 'https://{host}:{port}/seeyon/services/BPMService?wsdl'client = Client(form_url)print client'''获取模板(template)定义对象的XML组合,依次是[FlowExport, FormExport]'''template_export = client.service.getTemplateDefinition(token.id, "template")  # template是在A8系统上设定的模板的名称flowXml = template_export[0]print flowXmlprint "************************************************"formXml = template_export[1]print formXmlprint "************************************************"'''发起表单流程'''attachments = []response = client.service.launchFormCollaboration(token = token.id, senderLoginName = 'admin',                                                   templateCode = 'test1', subject = 'form_test1',                                                   date = '', attachments = attachments, param = '0')            print response         print "************************************************"            '''按时间段查询多个表单模板已经审批通过和结束的流程'''templates = ['template']flowId = client.service.getFormCollIdsByDateTime(token.id, templates, '2012-08-24 00:00:00', '2012-09-13 24:00:00')    print flowId print "************************************************"  '''获取某流程的流转状态'''state = client.service.getFlowState(token.id, flowId)   print state             

A8服务列表









原创粉丝点击