python-zeep
python-zeep copied to clipboard
Unable to attach xml file to message
I'm unable to attach a xml file in the zeep message. Code is below. The error I get is 'string indices must be integers'
I'm not a python developer by trade so please excuse the poor python (great language) below, or any common mistake I have made.
Thank you community :)
import PySimpleGUI as sg
import base64
from zeep import Client, Settings, xsd
from zeep.cache import SqliteCache
from zeep.transports import Transport
sg.theme('Dark Blue 3')
layout = [ [ sg.Text('XML REQUEST FILE:')],
[ sg.Input(key='XML'), sg.FileBrowse() ],
[ sg.Text('WSDL INPUT:')],
[ sg.Input(key="WSDL_LOC"), sg.FileBrowse()],
[ sg.Text('SERVICE LOCATION:')],
[ sg.InputText(key='SERVICE_LOCATION')],
[ sg.Ok('Submit Request') ],
[ sg.Output(size=(80,20)) ] ]
window = sg.Window('-- SOAP CLIENT -- ', layout)
while True:
event, values = window.Read()
if event is 'Submit Request':
settings = Settings(strict=True, xml_huge_tree=True )
transport = Transport(cache=SqliteCache())
values['WSDL_LOC'] = 'http://localhost:31656/Sample.asmx?WSDL'
values['XML'] = 'Sample.xml'
values['SERVICE_LOCATION'] = 'http://localhost:31656/example.asmx?op=submit'
client = Client(values['WSDL_LOC'], settings=settings, transport=transport)
with open(values['XML'], "b") as f:
byte = f.read()
print(type(byte)) #<byte>
try:
client.service.sampleSubmit(byte)
except Exception as ex:
print(ex)
continue;
if event is None:
break;
print(event, values);
```
Typically a service would take named parameters matching what that service. The byte is unlikely to be a valid name as it's not a string. Setting that byte to the correct parameter could be your way forward, but I assume you have progressed already.