Ignore:
Timestamp:
27/07/09 22:09:17 (11 years ago)
Author:
pjkersha
Message:

Working soap unit test with UrlLib2SOAPClient.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/soap/test_soap.py

    r5526 r5527  
     1#!/usr/bin/env python 
    12"""SOAP module unit test module 
    23 
     
    1617from cStringIO import StringIO 
    1718import paste.fixture 
    18 from urllib2 import HTTPHandler 
     19from urllib2 import HTTPHandler, URLError 
    1920 
    2021from ndg.security.common.soap.etree import SOAPEnvelope 
    21 from ndg.security.common.soap.client import UrlLib2SOAPClient 
     22from ndg.security.common.soap.client import UrlLib2SOAPClient, \ 
     23    UrlLib2SOAPRequest 
    2224 
    2325class SOAPBindingMiddleware(object): 
     
    2527     
    2628    def __call__(self, environ, start_response): 
     29        requestFile = environ['wsgi.input'] 
     30         
     31        print("Server received request from client:\n\n%s" %  
     32              requestFile.read()) 
     33         
    2734        soapResponse = SOAPEnvelope() 
    2835        soapResponse.create() 
     
    8390         
    8491        # ElementTree based envelope class 
    85         client.envelopeClass = SOAPEnvelope 
     92        client.responseEnvelopeClass = SOAPEnvelope 
    8693         
    8794        request = UrlLib2SOAPRequest() 
     
    8996        request.envelope = SOAPEnvelope() 
    9097        request.envelope.create() 
    91         request = client.soapClass() 
    92         request.create() 
    9398         
    9499        client.openerDirector.add_handler(HTTPHandler()) 
    95         response = client.makeRequest(request) 
     100        try: 
     101            response = client.send(request) 
     102        except URLError, e: 
     103            self.fail("soap_server.py must be running for this test") 
     104         
     105        print("Response from server:\n\n%s" % response.envelope.serialize()) 
    96106 
    97107if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.