我是C#的新手,我的主管希望我向Web服务发送SOAP请求并在C#中接收连接字符串。我曾经使用过Python,但我真的很困惑如何在C#中做到这一点。这是我写的Python代码。我真的迷路了。
import requests
url="http://172.20.3.3:8250/GS/GetConnectionStrings.asmx?WSDL"
#headers = {'content-type': 'application/soap+xml'}
headers = {'content-type': 'text/xml'}
body = """<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<DatabaseConnectionString xmlns='http://tempuri.org/'>
<DatabaseName>LMA</DatabaseName>
</DatabaseConnectionString>
</soap:Body>
</soap:Envelope>"""
response = requests.post(url,data=body,headers=headers)
print response.content
我需要将上面的代码转换为C#。