(May-22-2019, 08:44 AM)heiner55 Wrote: Maybe you should also show us your code.
The code throws an error at the end when I call this line
Quote: response = client.service.exportUsers()
import codecs
import logging
import sys
try:
from suds.bindings import binding
from suds.client import Client, WebFault
from suds.sax.element import Element
except ImportError as err:
error = "The suds (suds-jurko) module is required to run this program."
logger.critical(error)
logger.critical("Import error occurred: {0}".format(err))
raise ImportError(error)
def webService(username: str, password: str, url: str, output: bool = False,
url_timeout: int = 600,
output_csv: str = "dataoutput.csv") -> None:
"""
:type username: str
:type password: str
:type url: str
:type output: bool
:type timeout: int
:type output_csv: str
:type: None
"""
try:
pass
# Inspect service object to get a list of methods provide by the service
# Create a web service client
if logger.isEnabledFor(logging.INFO):
logger.info("Creating web service client for: {0}".format(ws_url))
client = Client(ws_url)
if ws_output_client:
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Web service client: {0}".format(client))
# Manually override the namespace being used for SOAP envelope as the
# Guidewire web services do not like the suds-jurko default of
# http://schemas.xmlsoap.org/soap/envelope/
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Changing the default SOAP binding environment namespace.")
binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope')
# Specify the SOAP Header namespace
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Specifying the SOAP header namespace.")
gwsoap = ('soap1', 'http://guidewire.com/ws/soapheaders')
# Add Elements to the SOAP Header in order to make the web service call
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Adding elements to the SOAP header.")
soap_header_locale = Element('locale', ns=gwsoap).setText('en_ZA')
soap_header_authentication = Element('authentication', ns=gwsoap)
soap_header_username = Element('username', ns=gwsoap).setText(username)
soap_header_password = Element('password', ns=gwsoap).setText(password)
soap_header_authentication.append(soap_header_username)
soap_header_authentication.append(soap_header_password)
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Setting the SOAP header options")
client.set_options(soapheaders=[soap_header_locale, soap_header_authentication])
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Setting the web service timeout to {0} seconds.".format(ws_url_timeout))
client.set_options(timeout=ws_url_timeout)
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Setting the web service port.")
client.set_options(port='UserExportServiceSoap12Port')
if logger.isEnabledFor(logging.INFO):
logger.info("Calling web service: {0}".format(ws_url))
response = client.service.exportUsers()
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Web service call complete.")
logger.debug("Web service call response output: {0}".format(response))
except WebFault as err:
logger.critical("WebFault error occurred: {0}".format(err))
except Exception as err:
logger.critical("Unknown error occurred: {0}".format(err))
finally:
return None