python WSDL.Proxy behind a http proxy

667 views Asked by At

I have a simple code that works when I'm not behind any proxy but doesn't work when I am behind a proxy. So is there any way I can specify that the connection has to be made through the http_proxy in the constructor of WSDL.Proxy class? I have been trying out ideone.py.

1

There are 1 answers

0
Pedro Romano On BEST ANSWER

You'll have to apply the following patch to ideone.py:

diff --git a/ideone.py b/ideone.py
index fffdf27..b15abef 100644
--- a/ideone.py
+++ b/ideone.py
@@ -42,10 +42,10 @@ def getError(response):


 class IdeOne:
-    def __init__(self, user='test', password='test'):
+    def __init__(self, user='test', password='test', **kwargs):
         self._user = user
         self._password = password
-        self._wsdlObject = WSDL.Proxy('http://ideone.com/api/1/service.wsdl')
+        self._wsdlObject = WSDL.Proxy('http://ideone.com/api/1/service.wsdl', **kwargs)

     def testFunction(self):
         response = self._wsdlObject.testFunction(self._user, self._password)

This will allow passing keyword arguments to the WSDL.Proxy which will be used to create its internal Client.SOAPProxy instance. Client.SOAPProxy has a http_proxy keyword argument, so then, after the patch applied, IdeOne(user='test', password='test', http_proxy='the.http.proxy') should work.