什么是.NET类,以替换旧的MSXML2.ServerXMLHTTP? [英] What are .NET classes to replace the old MSXML2.ServerXMLHTTP?
问题描述
我需要将旧项目从VbScript迁移到C#,即使我可以使用MSXML2.ServerXMLHTTP添加引用,也希望将其替换为.NET中较新的本机类.有哪些选择?
I need to migrate an old project from VbScript to C# and even if I can use MSXML2.ServerXMLHTTP adding a reference, I wish to replace it with a newer native class in .NET. What are the options?
这是VbScript中的一种请求,我必须替换该请求才能发送XML请求并接收XML作为响应:
This is the kind of request in VbScript I have to replace to send an XML request and receive XML in response:
Set xml1 = CreateObject("MSXML2.DOMDocument")
xml1.SetProperty "ServerHTTPRequest", False
xml1.Async = False
xml1.Loadxml xmlrqst
Set XMLhttp = CreateObject("MSXML2.ServerXMLHTTP")
XMLhttp.Open "POST", "https://weblink.tsdasp.net/10715xml.asp", False
XMLhttp.Send xml1.xml
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.loadXML XMLhttp.responseText
Set objLst = xmlDoc.getElementsByTagName("Message")
推荐答案
对于基本的GET/POST HTTP请求,您可以使用 WebClient
类或更新的 HttpClient
For basic GET/POST HTTP Requests, you can use the WebClient
class, or the newer HttpClient
.
对于XML,您可以使用 XmlDocument
类或 XDocument
.XmlDocument类甚至可以自己通过HTTP加载文档.
For XML, you can use the XmlDocument
class or XDocument
. The XmlDocument class can even load documents via HTTP by itself.
这篇关于什么是.NET类,以替换旧的MSXML2.ServerXMLHTTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!