在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ python調(diào)用webservice接口字典問題

python調(diào)用webservice接口字典問題

1、我在使用suds庫去掉用web service接口時候的語法問題?

2、下圖是接口文檔

webservice接口文檔
3、這是我調(diào)用時所寫的代碼

圖片描述

4、當(dāng)我運(yùn)行的時候抱錯誤:

  File "import.py", line 8, in <module>
    res = client.service['ISysSynchroGetOrgWebServicePort'].getUpdatedElements(t).message
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/client.py", line 576, in invoke
    soapenv = binding.get_message(self.method, args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/bindings/binding.py", line 109, in get_message
    content = self.bodycontent(method, args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/bindings/document.py", line 95, in bodycontent
    add_param, self.options().extraArgumentErrors)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/argparser.py", line 83, in parse_args
    return arg_parser(args, kwargs, extra_parameter_errors)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/argparser.py", line 108, in __call__
    self.__process_parameters()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/argparser.py", line 299, in __process_parameters
    self.__process_parameter(*pdef)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/argparser.py", line 294, in __process_parameter
    self.__in_choice_context(), value)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/bindings/document.py", line 86, in add_param
    p = self.mkparam(method, pdef, value)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/bindings/document.py", line 130, in mkparam
    return Binding.mkparam(self, method, pdef, object)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/bindings/binding.py", line 225, in mkparam
    return marshaller.process(content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/core.py", line 59, in process
    self.append(document, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/core.py", line 72, in append
    self.appender.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 88, in append
    appender.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 229, in append
    Appender.append(self, child, cont)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 168, in append
    self.marshaller.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/core.py", line 72, in append
    self.appender.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 88, in append
    appender.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 284, in append
    Appender.append(self, parent, cont)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 168, in append
    self.marshaller.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/core.py", line 72, in append
    self.appender.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 88, in append
    appender.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 229, in append
    Appender.append(self, child, cont)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/appender.py", line 168, in append
    self.marshaller.append(parent, content)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/core.py", line 71, in append
    if self.start(content):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/suds/mx/literal.py", line 86, in start
    raise TypeNotFound(content.tag)
suds.TypeNotFound: Type not found: 'type'

5、我初步理解是因?yàn)樽值鋬?nèi)有嵌套字典,不知道理解的對不對,如果把"returnOrgType": [{"type": "person", "type": "dept"}]這段去掉程序是可以運(yùn)行的,然而接口文檔也說明是必須要用這樣的格式來獲取相關(guān)的字段,請問這個問題該如何解決呢 ?

回答
編輯回答
胭脂淚

不寫了是 json 么。

json.dumps([{'type': 'a'}, {'type': 'b'}])
2017年8月27日 02:37