Python Forum
Error trying to Calling web service
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error trying to Calling web service
#1
Hi,

I'm getting this error below trying to call Web Service, can some help me as to what does it mean?

I took the working code and now trying to change the web url link.

Error:
CRITICAL WebFault error occurred: ((Fault){ Code = (Code){ Value = "soap12:Receiver" } Reason = (Reason){ Text = "java.lang.reflect.UndeclaredThrowableException" } }, <suds.sax.document.Document object at 0x000001F43739BC50>)
Reply
#2
Maybe you should also show us your code.
Reply
#3
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyscript index error while calling input from html form pyscript_dude 2 938 May-21-2023, 08:17 AM
Last Post: snippsat
Bug maximum recursion depth exceeded while calling a Python object error in python3 Prezess 4 3,689 Aug-02-2020, 02:21 PM
Last Post: deanhystad
  Create Service like window service jesssajan 3 2,948 Mar-06-2020, 01:09 PM
Last Post: ibreeden
  Py4JJavaError: An error occurred while calling o22720.csv. twinpiques 0 3,933 Jul-11-2019, 12:41 AM
Last Post: twinpiques
  when calling module comes up with syntax error DAS 5 3,752 Nov-27-2017, 01:50 PM
Last Post: sparkz_alot
  calling python function in c++ callback getting segmentation fault error Jotirling 3 7,122 Oct-26-2017, 08:55 AM
Last Post: Larz60+
  Calling to API service julius 2 2,875 Aug-25-2017, 04:54 PM
Last Post: julius

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020