def test02SendQuery(self):
        query_binding = AttributeQuerySslSOAPBinding()
        
        attribute_query = AttributeQueryFactory.create()
        attribute_query.subject.nameID.format = self.__class__.SUBJECT_FORMAT
        attribute_query.subject.nameID.value = self.__class__.SUBJECT
        attribute_query.issuerName = '/O=Site A/CN=Authorisation Service'


        attribute = Attribute()
        attribute.name = 'urn:ndg:saml:emailaddress'
        attribute.friendlyName = 'emailAddress'
        attribute.nameFormat = 'http://www.w3.org/2001/XMLSchema'
        
        attribute_query.attributes.append(attribute)
        
        query_binding.clockSkewTolerance = 2.
        query_binding.sslCACertDir = self.__class__.CLIENT_CACERT_DIR
        query_binding.sslCertFilePath = self.__class__.CLIENT_CERT_FILEPATH
        query_binding.sslPriKeyFilePath = self.__class__.CLIENT_PRIKEY_FILEPATH
        query_binding.sslValidDNs = self.__class__.VALID_DNS
        
        response = query_binding.send(attribute_query, 
                                      uri=self.__class__.SERVICE_URI)
        
        # Convert back to ElementTree instance read for string output
        samlResponseElem = ResponseElementTree.toXML(response)
        
        print("SAML Response ...")
        print(ElementTree.tostring(samlResponseElem))
        print("Pretty print SAML Response ...")
        print(prettyPrint(samlResponseElem))
        
        self.assert_(response.status.statusCode.value==StatusCode.SUCCESS_URI)
    def dispatch(self, command):
        if command == self.__class__.ATTRIBUTE_QUERY_CMD:
            query = self.create_attribute_query()
            binding = AttributeQuerySslSOAPBinding()
            
        elif command == self.__class__.AUTHZ_DECISION_QUERY_CMD:
            query = self.create_authz_decision_query()
            binding = AuthzDecisionQuerySslSOAPBinding()

        binding.sslCACertDir = self.ca_cert_dir
        binding.sslCertFilePath = self.client_cert_filepath
        binding.sslPriKeyFilePath = self.client_prikey_filepath
        binding.clockSkewTolerance = self.clock_skew_tolerance

        response = binding.send(query, uri=self.service_uri)
        
        return response