add GCAP interface
Showing
3 changed files
with
43 additions
and
0 deletions
... | @@ -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><Request><Framework><UserName>SFCHINA\qqcout0</UserName><GUID>70d0efcb-3bc2-4018-ac4e-681c8f3131b6</GUID><DetailedTracingEnabled>False</DetailedTracingEnabled><ServiceName>AMSWebService</ServiceName><SupportsRedirection>true</SupportsRedirection><ServiceType>Service</ServiceType></Framework><Parms><InputXML type="string">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;InputXML&gt; &lt;Result&gt; {0} &lt;/Result&gt;&lt;AuthorizationData&gt;&lt;ServiceComponent&gt;OCR&lt;/ServiceComponent&gt;&lt;RoleId/&gt;&lt;CompanyId/&gt;&lt;/AuthorizationData&gt;&lt;/InputXML&gt;</InputXML></Parms></Request></strXMLParm></Exec>]]>""" | ||
1020 | ... | ... |
src/apps/doc/ocr/gcap.py
0 → 100644
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 |
src/common/tools/dict_to_xml.py
0 → 100644
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment