0

我在 Ubuntu 13.04 上使用 Python 2.7。我需要使用 SOAP API,但在尝试使用其中一项服务时遇到了问题。这是 wsdl 网址:http ://www.educationconnection.com/ecsleadapi/version4_1/service.svc?wsdl

如果我在 iPython 中输入以下内容,一切都很好:

from suds.client import Client
client = Client('<wsdl_url>')
kwargs = {'UserName': '<my_username>', 'Password': '<my_password>', 'SchoolID': 29, 'CampusID': 156}
client.service.GetCampus(**kwargs)

输出符合预期。

如果我在脚本中有完全相同的代码,则会收到以下错误:

  File "/home/ricomoss/.virtualenvs/scripts/local/lib/python2.7/site-packages/suds/client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "/home/ricomoss/.virtualenvs/scripts/local/lib/python2.7/site-packages/suds/client.py", line 602, in invoke
    result = self.send(soapenv)
  File "/home/ricomoss/.virtualenvs/scripts/local/lib/python2.7/site-packages/suds/client.py", line 649, in send
    result = self.failed(binding, e)
  File "/home/ricomoss/.virtualenvs/scripts/local/lib/python2.7/site-packages/suds/client.py", line 702, in failed
    r, p = binding.get_fault(reply)
  File "/home/ricomoss/.virtualenvs/scripts/local/lib/python2.7/site-packages/suds/bindings/binding.py", line 265, in get_fault
    raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.'

我还使用soapUI 来验证服务调用。除我的脚本外,一切正常。有任何想法吗?

提供更多代码……这是我为服务调用编写的包装器。

def __init__(self, **kwargs):
    self.wsdl = kwargs.get('wsdl', self.DEFAULT_WSDL)
    self.username = kwargs.get('username', self.ED_USERNAME)
    self.password = kwargs.get('password', self.ED_PASSWORD)
    self.client = Client(self.wsdl)

def get_schools(self):
    return self.client.service.GetSchools(
        UserName=self.username, Password=self.password)

def get_campus(self, school_id, campus_id):
    return self.client.service.GetCampus(
        SchoolId=school_id, CampusID=campus_id,
        UserName=self.username, Password=self.password)

def get_program(self, school_id, campus_id, program_id):
    return self.client.service.GetProgram(
        UserName=self.username, Password=self.password,
        CampusID=campus_id, ProgramID=program_id, SchoolID=school_id)
4

1 回答 1

0

正如 Thomas Fenzl 指出的:

该脚本在 GetCampus 关键字 args 中有错字。(学校 ID -> 学校 ID)

于 2013-06-12T17:47:57.420 回答