source: TI12-security/trunk/python/Tests/Echo/EchoServer_client.py @ 1542

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/Echo/EchoServer_client.py@1542
Revision 1542, 1.5 KB checked in by pjkersha, 15 years ago (diff)

Added http proxy handling for ZSI - see Tests/Echo?/urllib2Client.py

Line 
1##################################################
2# EchoServer_client.py
3# generated by ZSI.generate.wsdl2python
4##################################################
5
6
7
8import urlparse, types
9from ZSI.TCcompound import ComplexType, Struct
10from ZSI import client
11import ZSI
12from urllib2Client import URLlib2Binding
13
14from EchoServer_messages import EchoRequest, EchoResponse
15
16
17# Locator
18class EchoServerLocator:
19    EchoServer_address = "http://localhost:7000"
20    def getEchoServerAddress(self):
21        return EchoServerLocator.EchoServer_address
22    def getEchoServer(self, url=None, **kw):
23        return EchoServerSOAP(url or EchoServerLocator.EchoServer_address, **kw)
24
25# Methods
26class EchoServerSOAP:
27    def __init__(self, url, **kw):
28        kw.setdefault("readerclass", None)
29        kw.setdefault("writerclass", None)
30        # no resource properties
31        self.binding = URLlib2Binding(url=url, **kw)
32        # no ws-addressing
33
34    # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6edcf8c>
35    def Echo(self, EchoIn):
36
37        request = EchoRequest()
38        request.EchoIn = EchoIn
39
40        import urllib2
41        proxies = {'http_proxy': 'http://wwwcache2.rl.ac.uk:8080'}
42        kw = {'urlHandler': urllib2.ProxyHandler(proxies=proxies)}
43       
44        # no input wsaction
45        self.binding.Send(None, None, request, soapaction="Echo", **kw)
46       
47        # no output wsaction
48        response = self.binding.Receive(EchoResponse.typecode)
49        EchoResult = response.EchoResult
50        return EchoResult
Note: See TracBrowser for help on using the repository browser.