分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

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

发布时间:2023-09-06 01:58责任编辑:沈小雨关键词:暂无标签

一、正常调用

1 # coding:utf-82 from suds.client import Client3 4 if __name__ == ‘__main__‘:5 ????client = Client(‘http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl‘)6 ????print client.service.getMobileCodeInfo(‘15116020790‘, ‘‘)7 8 ## result9 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 dependencies10 ????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 client12 ????print client.service.getWeatherbyCityName(u‘上海‘)13 14 ## result15 (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错误

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved