how do you send a SOAP request?

前端 未结 5 946
攒了一身酷
攒了一身酷 2021-02-05 10:04

I am new to SOAP and xml. I read a number of tutorials but nothing seems to be clear enough.

I am abit confused, Just how does one send an SOAP request? The way I have t

5条回答
  •  生来不讨喜
    2021-02-05 10:42

    This blog post helped me. Python SOAP Request using Requests

    #!/usr/bin/env python
    # encoding: utf-8
    
    import requests
    from XML import XML
    
    request = u"""
                  
                      
                      
                          
                              GBP
                              CHF
                          
                      
                  """
    
    encoded_request = request.encode('utf-8')
    
    headers = {"Host": "www.webservicex.net",
               "Content-Type": "text/xml; charset=UTF-8",
               "Content-Length": len(encoded_request)}
    
    response = requests.post(url="http://www.webservicex.net/CurrencyConvertor.asmx",
                             headers = headers,
                             data = encoded_request,
                             verify=False)
    
    print unicode(XML(response.text))
    

提交回复
热议问题