0

I have a problem with WSDL operation name:import. It is one of the most important remote operation, that update product list on the remote server.

The problem starts when I want to call the method:

client.service.import('ns0:Product_Import', _soapheaders = [header_value])
node = client.service.import(product_name)
                           ^
SyntaxError: invalid syntax

because the 'import' statement is reserved to the python. How to make that calling this method does not interfere with python?

This code below works fine. Maybe someone will use it.

from zeep import Client
from zeep import xsd

loginIn = {'username': 'my_username', 'password': 'my_password'}
wsdl_auth = 'http://some-wsdl-service.com/auth/wsdl/'
wsdl_products = 'http://some-wsdl-service.com/products/wsdl/'
header = xsd.Element(
'{http://some-wsdl-service.com/products/wsdl/}Header',
    xsd.ComplexType([
        xsd.Element(
            '{http://some-wsdl-service.com/products/wsdl/}sessionId',
            xsd.String()
       ),
   ])
)
client = Client(wsdl = wsdl_auth)
response = client.service.login(loginIn)
sid = response.sessionId
header_value = header(sessionId = sid)
client = Client(wsdl = wsdl_products)
list_of_products = client.service.get('ns0:Product_List',        
                                      _soapheaders [header_value])
client = Client(wsdl = wsdl_auth)
request_to_end = client.service.logout(_soapheaders=[header_value]))
Jarex
  • 3
  • 2

1 Answers1

1

You can use getattr() to access methods in client.service

_import = getattr(client.service, 'import')
result = _import(product_name)
galmeriol
  • 461
  • 4
  • 14