我最近的任务是将经典的ASP Web应用程序升级到C#。一切都很好,除了有一些代码使用Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
。我甚至不知道这是什么,除非我有一般的想法,即它被用来以某种方式通过HTTPS调用Web服务。如何将使用Msxml2.ServerXMLHTTP.3.0的VBScript应用程序升级到C#?
的代码看起来是这样的:
Dim strSOAPEnvelope
strSOAPEnvelope = "<?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>..........</soap:Body>" & _
"</soap:Envelope>"
oXMLHttp.Open "POST", "https://example.com/service.asmx", False
oXMLHttp.setRequestHeader "Content-Type", "text/xml"
oXMLHttp.setOption 2, 13056
oXMLHttp.setRequestHeader "Connection", "close"
oXMLHttp.setRequestHeader "SOAPAction", "https://example.com" & strfunction
我想我明白,这是通过HTTPS一个Web服务通信的一般概念。如何将此代码升级到C#
您可能有兴趣知道该语言被命名为“C#”,而不是“C#.NET”。 – 2012-02-13 22:25:55