ab5ef471 by 周伟奇

add GCAP interface

1 parent e5726dfc
...@@ -1004,3 +1004,17 @@ ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID', 'ITUSC', 'ITCCU ...@@ -1004,3 +1004,17 @@ ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID', 'ITUSC', 'ITCCU
1004 SECOND_ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID'] 1004 SECOND_ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID']
1005 SUB_TYPE = ['CSIBM', 'CSOTH', 'CSSME'] 1005 SUB_TYPE = ['CSIBM', 'CSOTH', 'CSSME']
1006 1006
1007 # GCAP 请求体
1008 BASE_XML_TEXT = """<?xml version="1.0" encoding="utf-8"?>
1009
1010 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://guardean.net/webservices/workflow/vatra_bmwservice/types">
1011 <soapenv:Header/>
1012 <soapenv:Body>
1013 <typ:executeRequest>
1014 <request>{0}</request>
1015 </typ:executeRequest>
1016 </soapenv:Body>
1017 </soapenv:Envelope>"""
1018
1019 CDATA_TEXT = """<![CDATA[<Exec xmlns="http://tempuri.org/"><strXMLParm>&lt;Request&gt;&lt;Framework&gt;&lt;UserName&gt;SFCHINA\qqcout0&lt;/UserName&gt;&lt;GUID&gt;70d0efcb-3bc2-4018-ac4e-681c8f3131b6&lt;/GUID&gt;&lt;DetailedTracingEnabled&gt;False&lt;/DetailedTracingEnabled&gt;&lt;ServiceName&gt;AMSWebService&lt;/ServiceName&gt;&lt;SupportsRedirection&gt;true&lt;/SupportsRedirection&gt;&lt;ServiceType&gt;Service&lt;/ServiceType&gt;&lt;/Framework&gt;&lt;Parms&gt;&lt;InputXML type="string"&gt;&amp;lt;?xml version="1.0" encoding="utf-16"?&amp;gt;&amp;lt;InputXML&amp;gt; &amp;lt;Result&amp;gt; {0} &amp;lt;/Result&amp;gt;&amp;lt;AuthorizationData&amp;gt;&amp;lt;ServiceComponent&amp;gt;OCR&amp;lt;/ServiceComponent&amp;gt;&amp;lt;RoleId/&amp;gt;&amp;lt;CompanyId/&amp;gt;&amp;lt;/AuthorizationData&amp;gt;&amp;lt;/InputXML&amp;gt;&lt;/InputXML&gt;&lt;/Parms&gt;&lt;/Request&gt;</strXMLParm></Exec>]]>"""
1020
......
1 import requests
2 from requests.auth import HTTPBasicAuth
3 from settings import conf
4 from common.tools.dict_to_xml import dicttoxml, escape_xml
5 from apps.doc import consts
6
7
8 class GCAP:
9
10 def __init__(self):
11 self.url = conf.GCAP_URL
12 self.headers = {
13 'Content-Type': 'text/plain',
14 }
15 self.auth = HTTPBasicAuth(conf.GCAP_AUTH_USER, conf.GCAP_AUTH_PWD)
16
17 @staticmethod
18 def dict_to_xml(comparison_res):
19 comparison_xml = dicttoxml(comparison_res, root=False, attr_type=False)
20 return consts.BASE_XML_TEXT.format(consts.CDATA_TEXT.format(escape_xml(comparison_xml))).encode('utf-8')
21
22 def send(self, comparison_res):
23 data = self.dict_to_xml(comparison_res)
24 response = requests.post(self.url, headers=self.headers, data=data, verify=False, auth=self.auth)
25 return response
26
27
28
29
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!