【发布时间】:2020-12-31 08:22:00
【问题描述】:
我正在为客户打造 ASIC(澳大利亚)商业登记 (BRS) 应用程序。 UAT 中的 ASIC SOAP API 在soap 响应中的服务绑定中有一个错误。它返回一个不正确的 URL。
【问题讨论】:
我正在为客户打造 ASIC(澳大利亚)商业登记 (BRS) 应用程序。 UAT 中的 ASIC SOAP API 在soap 响应中的服务绑定中有一个错误。它返回一个不正确的 URL。
【问题讨论】:
以下代码解决了这个问题:
def your_wsdl(DocumentHeader, DocumentBody):
"""Call ASIC using the SOAP API listin the BRS document
:param DocumentHeader: dictonary with the fields as specifed in BRS documentation
:param DocumentBody: dictonary with the fields as specifed in BRS documentation
"""
wsdl = Config.objects.get(code="ASIC_API").value + str('?WSDL')
wsdl_session = Session()
wsdl_session.auth = HTTPBasicAuth(Config.objects.get(code="ASIC_API_ID").value, Config.objects.get(code="ASIC_API_PASS").value)
transport = Transport(session=wsdl_session)
client = Client(wsdl, transport=transport)
##get_service2 fixes the incorrect binding response in BRS UAT
service = get_service2(client=client)
soap_response={}
with client.settings(raw_response=True, xsd_ignore_sequence_order=False):
try:
soap_response= service.externalInitiat
except Exception as e:
soap_response = { 'status_code': 500 }
def get_service2(客户端):
"""Fix for the incorrect Service Binding
:param client: soap client object
"""
service_binding = client.service._binding.name
service_address = Config.objects.get(code="ASIC_API_url").value
return client.create_service(service_binding, service_address)
【讨论】: