ws0 = CompositeOperationRequest()
ws0.login = login
# Anexando as requisições dos Dois Web Services anteriores no Composite
ws0.operations.append(Operation(ws1))
ws0.operations.append(Operation(ws2))
ws0.web_service_type = 'CompositeBPartnerTest'

# Criando Conexão
wsc = WebServiceConnection()
wsc.url = urls
wsc.attempts = 3
wsc.app_name = 'Test from python'

# Enviando Requisição
try:
    response = wsc.send_request(ws0)
    wsc.print_xml_request()
    wsc.print_xml_response()

    # Recebendo e Exibindo a Resposta
    if response.status == WebServiceResponseStatus.Error:
        print('Error: ', response.error_message)
    else:
        print('Response: ', str(response.web_service_response_model()))
        for res in response.responses:
            print('Response: ', str(res.web_service_response_model()))
        print('-' * 45)
        print('Web Service Type: ', ws0.web_service_type)
        print('Attempts: ', str(wsc.attempts_request))
        print('Time: ', str(wsc.time_request))
except:
login.password = '******'
login.user = '******'

query = QueryDataRequest()
query.web_service_type = 'QueryImageTest'
query.offset = 5
query.limit = 1
query.login = login

wsc = WebServiceConnection()
wsc.url = url
wsc.attempts = 3
wsc.app_name = 'Test from python'

try:
    response = wsc.send_request(query)
    wsc.print_xml_request()
    wsc.print_xml_response()

    if response.status == WebServiceResponseStatus.Error:
        print('Error: ', response.error_message)
    else:
        print('Total Rows: ', str(response.total_rows))
        print('Num rows: ', str(response.num_rows))
        print('Start row: ', str(response.start_row))
        print('')
        for row in response.data_set:
            for field in row:
                print('{}: {}'.format(str(field.column), str(field.value)))
                if str(field.column) == 'BinaryData':
                    with open('newFile.png', 'wb') as file:
Beispiel #3
0
"""

"""
Contributor: @pozzisan <*****@*****.**>
"""

from brerpwsc.net import WebServiceConnection

url = 'http://teste.brerp.com.br/ADInterface/services/ModelADService'
urls = 'https://localhost:8431/ADInterface/services/ModelADService'


def test_xml():
    test_file = open('../documents/ReadBPartnerTest_request.xml', 'r')
    return test_file.read()


wsc = WebServiceConnection()
wsc.url = url
wsc.attempts = 3
try:
    response = wsc.send_request(test_xml())
except Exception as e:
    print('Error', str(e))
else:
    wsc.print_xml_response()
finally:
    print(wsc.attempts_request)
    print(wsc.time_request)
    print(wsc.response_status)