This is my first time posting here. I’m trying to run through the sample code first before attempting my own project. I selected Python version that uses SOAPpy
from SOAPpy import Config, HTTPTransport, SOAPAddress, WSDL username = 'myusername' apiKey = '0axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' wsdlFile = 'http://flightxml.flightaware.com/soap/FlightXML2' # This is a custom HTTP transport that allows Basic Authentication. class myHTTPTransport(HTTPTransport): username = None passwd = None @classmethod def setAuthentication(cls,u,p): cls.username = u cls.passwd = p def call(self, addr, data, namespace, soapaction=None, encoding=None, http_proxy=None, config=Config): if not isinstance(addr, SOAPAddress): addr=SOAPAddress(addr, config) if self.username != None: addr.user = self.username+":"+self.passwd return HTTPTransport.call(self, addr, data, namespace, soapaction, encoding, http_proxy, config) # Make a FlightXML server request. myHTTPTransport.setAuthentication(username, apiKey) DF = WSDL.Proxy(wsdlFile, transport=myHTTPTransport) enroute = DF.Enroute('KSMO',10,'',0) flights = enroute'enroute'] print "Aircraft en route to KSMO:" for flight in flights: print "%s (%s) %s (%s)" % ( flight'ident'], flight'aircrafttype'], flight'originName'], flight'origin'])
The code throws the exact same error for me using my username/apikey pair as it does for the sample stuff that was provided.
The error I get is as follows:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\XXXX\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile execfile(filename, namespace) File "C:\XXXX\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc) File "FlightAwareSample.py", line 42, in <module> DF = WSDL.Proxy(wsdlFile, transport=myHTTPTransport) File "C:\XXXX\Anaconda\lib\site-packages\SOAPpy\WSDL.py", line 85, in __init__ self.wsdl = reader.loadFromString(str(wsdlsource)) File "C:\XXXX\Anaconda\lib\site-packages\wstools\WSDLTools.py", line 52, in loadFromString return self.loadFromStream(StringIO(data)) TypeError: initial_value must be unicode or None, not str
Note: I’ve redacted some of the file paths
When I spoke with support they said that my username/apikey pair was correct. I do get the following error when I try to go to http://flightxml.flightaware.com/soap/FlightXML2 which is the wsdlFile
The requested resource
is no longer available on this server and there is no forwarding address. Please remove all references to this resource.
Any help you can offer would be much appreciated