source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/wsSecurity/EchoServer_client.py @ 1696

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/wsSecurity/EchoServer_client.py@3107
Revision 1696, 1.7 KB checked in by pjkersha, 13 years ago (diff)

Working test code for ZSI Web Service using Twisted:

  • for server, used wsdl2dispatch - but make sure to edit the return types

in AttAuthority_services_server server class stubs to return request, response
tuple as required by Twisted interface. Created .tac file which loads a
sub class of the wsdl2dispatch generated class.

  • tested with standard ZSI client using stubs generated from wsdl2py. Also

tested with Twisted client - stubs generated with wsdl2py including the -w
option.

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
12
13from EchoServer_messages import *
14
15# Locator
16class EchoServerLocator:
17    EchoServer_address = "http://localhost:7100"
18    def getEchoServerAddress(self):
19        return EchoServerLocator.EchoServer_address
20    def getEchoServer(self, url=None, **kw):
21        return EchoServerSOAP(url or EchoServerLocator.EchoServer_address, **kw)
22
23# Methods
24class EchoServerSOAP:
25    def __init__(self, url, **kw):
26        kw.setdefault("readerclass", None)
27        kw.setdefault("writerclass", None)
28        # no resource properties
29        self.binding = client.Binding(url=url, **kw)
30        # no ws-addressing
31
32    # op: <ZSI.wstools.WSDLTools.Message instance at 0xb77f40ec>
33    def Echo(self, EchoIn):
34
35        request = EchoRequest()
36        request.EchoIn = EchoIn
37
38        kw = {}
39        # no input wsaction
40        self.binding.Send(None, None, request, soapaction="Echo", **kw)
41        # no output wsaction
42        response = self.binding.Receive(EchoResponse.typecode)
43        EchoResult = response.EchoResult
44        return EchoResult
45
46    # op: <ZSI.wstools.WSDLTools.Message instance at 0xb77f48cc>
47    def EchoEncr(self, EchoIn):
48
49        request = EchoEncrRequest()
50        request.EchoIn = EchoIn
51
52        kw = {}
53        # no input wsaction
54        self.binding.Send(None, None, request, soapaction="EchoEncr", **kw)
55        # no output wsaction
56        response = self.binding.Receive(EchoEncrResponse.typecode)
57        EchoResult = response.EchoResult
58        return EchoResult
Note: See TracBrowser for help on using the repository browser.