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

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-8

from 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 flowXml
print "************************************************"

formXml = template_export[1]
print formXml
print "************************************************"

'''
发起表单流程
'''
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服务列表









  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值