Answer the question
In order to leave comments, you need to log in
How to pull out the value received in the response to the request?
Hello! I send a SOAP request and get a response:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Response
xmlns="URL">
<message>ba53cf44-5610-40e3-8def-a8b031f1f930</message>
</Response>
</soapenv:Body>
</soapenv:Envelope>
import requests
url="URL"
#headers = {'content-type': 'application/soap+xml'}
headers = {'content-type': 'text/xml'}
body = """MY_SOAP_REQUEST"""
response = requests.post(url,data=body.encode('utf-8'),headers=headers)
answer = response.content.decode('UTF-8')
print(response)
Answer the question
In order to leave comments, you need to log in
Take and parse XML.
This is what happened to me: https://codecamp.ru/blog/python-manipulating-xml/
You can "head on" find a tag in the response <message>
and pull out the value through regexps or stupidly with find()
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question