Example #1
0
 def build_soap(self, xml_dict):
     #TODO build this up properly
     soap_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Header>
             <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                 <wsse:UsernameToken>
                     <wsse:Username>%(merchant_id)s</wsse:Username>
                     <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%(api_key)s</wsse:Password>
                 </wsse:UsernameToken>
             </wsse:Security>
         </soapenv:Header>
         <soapenv:Body>
         %(body)s
         </soapenv:Body>
     </soapenv:Envelope>
     '''
     root = ET.Element('requestMessage')
     root.attrib['xmlns'] = self.namespace
     dicttoxml(xml_dict, root)
     body = ET.tostring(root)
     return soap_payload % {
         'merchant_id': self.merchant_id,
         'api_key': self.api_key,
         'body': body,
     }
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     self.validate_request(msg)
     data = xmltodict(ET.fromstring(msg))
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     self.validate_response(ret)
     return ret
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     self.validate_request(msg)
     data = xmltodict(ET.fromstring(msg))
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     self.validate_response(ret)
     return ret
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     self.validate_request(msg)
     msg = msg.replace('xmlns="%s"' % self.namespace, '')
     data = xmltodict(ET.fromstring(msg))
     if '{http://schemas.xmlsoap.org/soap/envelope/}Body' in data:
         data = data['{http://schemas.xmlsoap.org/soap/envelope/}Body']['requestMessage']
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     self.validate_response(ret)
     return ret
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     #self.validate_request(msg)
     msg = msg.replace('xmlns="%s"' % self.namespace, '')
     data = xmltodict(ET.fromstring(msg))
     if '{http://schemas.xmlsoap.org/soap/envelope/}Body' in data:
         data = data['{http://schemas.xmlsoap.org/soap/envelope/}Body']['requestMessage']
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     #self.validate_response(ret)
     return ret
 def build_soap(self, xml_dict):
     #TODO build this up properly
     soap_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Header>
             <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                 <wsse:UsernameToken>
                     <wsse:Username>%(merchant_id)s</wsse:Username>
                     <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%(api_key)s</wsse:Password>
                 </wsse:UsernameToken>
             </wsse:Security>
         </soapenv:Header>
         <soapenv:Body>
         %(body)s
         </soapenv:Body>
     </soapenv:Envelope>
     '''
     root = ET.Element('requestMessage')
     root.attrib['xmlns'] = self.namespace
     dicttoxml(xml_dict, root)
     body = ET.tostring(root)
     return soap_payload % {'merchant_id': self.merchant_id,
                            'api_key': self.api_key,
                            'body': body,}
Example #7
0
 def __call__(self, url, msg, headers):
     msg = msg.replace('xmlns="http://www.paypal.com/XMLPay"', '') #arghhh, don't care to deal with namespaces
     data = xmltodict(ET.fromstring(msg))
     response = self.receive(data)
     return ET.tostring(self.send(data, response))