SOAP suds and the dreaded schema Type Not Found error

前端 未结 3 1382
心在旅途
心在旅途 2020-11-30 08:53

I\'m using the latest version of suds (https://fedorahosted.org/suds/) for the first time and I\'m getting stalled at step one.

suds.TypeNotFound: Type not          


        
相关标签:
3条回答
  • 2020-11-30 09:26

    We got it working and I hope you did as well, even though it is a bit quirky. Perhaps an explicit location or filter will help. E.g.:

    imp = Import(
        'http://schemas.xmlsoap.org/soap/encoding/',
        location='http://schemas.xmlsoap.org/soap/encoding/'
    )
    imp.filter.add('http://ws.client.com/Members.asmx')
    client = Client(url, plugins=[ImportDoctor(imp)])
    
    0 讨论(0)
  • 2020-11-30 09:29

    I was banging my head for a while on this one. I finally resolved the issue by using the following syntax:

    from suds.xsd.doctor import ImportDoctor, Import
    
    url = 'http://somedomain.com/filename.php?wsdl'
    imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
    imp.filter.add('http://some/namespace/A')
    doctor = ImportDoctor(imp)
    
    client = Client(url, doctor=doctor)
    

    Importantly, start with the url. Open that file in your browser and it will provide you with the wsdl definitions. Make sure you have the right url entered here and that an XML file actually opens. Also mind the ?wsdl at the end of the url.

    Second, imp = Import('http://schemas.xmlsoap.org/soap/encoding/') will import the standard SOAP schema.

    Third, imp.filter.add('http:somedomain.com/A') will add your specific namespace. You can find this namespace location by opening the url you defined above in url=and looking for the section <wsdl:import namespace="http://somedomain.com/A".

    Also be mindful of http vs https in your urls.

    0 讨论(0)
  • 2020-11-30 09:45

    For those who still is troubled by this problem. This link https://bitbucket.org/jurko/suds/issue/20/typenotfound-schema may provide useful information. The solution would be like this:

    from suds.client import Client
    from suds.xsd.doctor import Import, ImportDoctor
    
    url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'
    imp = Import('http://www.w3.org/2001/XMLSchema',
        location='http://www.w3.org/2001/XMLSchema.xsd')
    imp.filter.add('http://WebXml.com.cn/')
    client = Client(url, doctor=ImportDoctor(imp))
    
    0 讨论(0)
提交回复
热议问题