我正在为一个客户建立ASIC(澳大利亚)商业登记(BRS)应用程序。UAT中的ASIC SOAP API在soap响应内的服务绑定中存在缺陷。它会返回一个不正确的URL。
发布于 2020-12-31 16:22:01
下面的代码解决了这个问题:
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)https://stackoverflow.com/questions/65518389
复制相似问题