Django 找不到WSDL类型
我正在尝试使用django的suds获取WSDL响应。但我得到了一个类型未找到错误,没有任何原因Django 找不到WSDL类型,django,wsdl,suds,Django,Wsdl,Suds,我正在尝试使用django的suds获取WSDL响应。但我得到了一个类型未找到错误,没有任何原因 Type not found: 'ProfileInfo' 我的xml应该是这样的: <Profiles> <ProfileInfo> <Profile ProfileType="1"> <Customer> </Customer> </Profile> </
Type not found: 'ProfileInfo'
我的xml应该是这样的:
<Profiles>
<ProfileInfo>
<Profile ProfileType="1">
<Customer>
</Customer>
</Profile>
</ProfileInfo>
</Profiles>
没有ProfileInfo对象
profile_info = {"Profile": []}
profile_info["Profile"].append(profile)
profiles = client.factory.create('ns0:ProfilesType')
profiles.ProfileInfo.append(profile_info)
我就是这么做的:
我创建一个ProfilesType对象:
profiles = client.factory.create('ns0:ProfilesType')
此对象如下所示:
(ProfilesType){
ProfileInfo[] = <empty>
}
这将生成以下被服务器拒绝的XML
<Profiles>
<ProfileInfo>
<Customer>
</Customer>
</ProfileInfo>
</Profiles>
这会引发找不到错误类型:“ProfileInfo”
我该怎么办?我一直在尝试各种组合,但似乎没有任何效果。我将尝试使用肥皂水医生,可能会有所帮助,请参见: 这个答案让我走上了正确的轨道。进口医生不起作用,但这起作用: 我打开模式,查看缺少的类型引用的位置,找到了名称空间和位置,并在此处填写:
from suds.xsd.sxbasic import Import
ns = '<fill in the namespace for the missing type>'
schema_url = '<fill in the url>'
Import.bind(ns, location)
# repeat this for all missing types
# and than create the client
client = Client(wsdl_url)
message= '%s' % client
# log the message, and this works for me!
我必须创建一个虚拟的ProfileInfo对象
profile_info = {"Profile": []}
profile_info["Profile"].append(profile)
profiles = client.factory.create('ns0:ProfilesType')
profiles.ProfileInfo.append(profile_info)
找到这个了吗?我也有同样的问题。如果你解决了,请分享解决方案
from suds.xsd.sxbasic import Import
ns = '<fill in the namespace for the missing type>'
schema_url = '<fill in the url>'
Import.bind(ns, location)
# repeat this for all missing types
# and than create the client
client = Client(wsdl_url)
message= '%s' % client
# log the message, and this works for me!
profile_info = {"Profile": []}
profile_info["Profile"].append(profile)
profiles = client.factory.create('ns0:ProfilesType')
profiles.ProfileInfo.append(profile_info)