码迷,mamicode.com
首页 > Web开发 > 详细

suds调用webserive时出现suds.TypeNotFound错误

时间:2018-06-05 00:36:34      阅读:1725      评论:0      收藏:0      [点我收藏+]

标签:天气   issues   参考   cto   ror   self   city   空气质量   pac   

一、正常调用

1 # coding:utf-8
2 from suds.client import Client
3 
4 if __name__ == __main__:
5     client = Client(http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl)
6     print client.service.getMobileCodeInfo(15116020790, ‘‘)
7 
8 ## result
9 15116020790:湖南 株洲 湖南移动全球通卡

 

二、调用出现错误

 1 # coding: utf-8
 2 from suds.client import Client
 3 
 4 if __name__ == __main__:
 5     client = Client(http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl)
 6     print client
 7 
 8 ## result
 9 File "C:\project\Test\venv\lib\site-packages\suds\xsd\sxbasic.py", line 422, in dependencies
10     raise TypeNotFound(self.ref)
11 suds.TypeNotFound: Type not found: (schema, http://www.w3.org/2001/XMLSchema, )

 

三、解决方式

 1 # coding: utf-8
 2 from suds.client import Client
 3 from suds.xsd.doctor import ImportDoctor, Import
 4 
 5 if __name__ == __main__:
 6     imp = Import(http://www.w3.org/2001/XMLSchema,
 7                  location=http://www.w3.org/2001/XMLSchema.xsd)
 8     imp.filter.add(http://WebXml.com.cn/)
 9     doctor = ImportDoctor(imp)
10     client = Client(http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl, doctor=doctor)
11     # print client
12     print client.service.getWeatherbyCityName(u上海)
13 
14 ## result
15 (ArrayOfString){
16    string[] = 
17       "直辖市",
18       "上海",
19       ...,
20       "今日天气实况:气温:23℃;风向/风力:静风 0级;湿度:77%;紫外线强度:弱。空气质量:中。", ...
21  }

 

参考:

https://stackoverflow.com/questions/4719854/soap-suds-and-the-dreaded-schema-type-not-found-error

https://bitbucket.org/jurko/suds/issues/20/typenotfound-schema

suds调用webserive时出现suds.TypeNotFound错误

标签:天气   issues   参考   cto   ror   self   city   空气质量   pac   

原文地址:https://www.cnblogs.com/elephanyu/p/9136556.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!