1

Following code does not work for me on Win Server 2003 machine but works on XP. I have installed SOAP Toolkit 3.0 installed on server. What could be a reason?

  • Have you tried running the script on the Windows Server 2003 machine outside of IIS, i.e. replace Server.CreateObject with CreateObject and Response.Write with MsgBox and save as a VBS? That should tell you if the server is capable of creating the objects without getting IIS involved. – boflynn Apr 21 '09 at 20:12
  • I have tried the code in .vbs file. It gives me error as: ActiveX component can't create object: 'MSSOAP.SoapClient30' –  Apr 27 '09 at 10:40
  • I has a similar issue with Windows Server 2008 64 bit. Is your server that is having the problem also 64 bit? – Ken Burkhardt Apr 15 '10 at 20:51
  • Looking at this question really reiterates why I love Restful Json web services. – Jeremy Apr 29 '12 at 23:33

1 Answers1

5

'Here is another way to consume .NET web service in classic ASP.

<html>
    <head><title></title></head>
    <body>


    <%    
        Dim objHTTP, strEnvelope
        Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")

        'Create the SOAP Envelope.
        'Start with standard xml name space and XML Schema Definition.
        strEnvelope = "<?xml version='1.0' encoding='utf-8'?>"
        strEnvelope = strEnvelope & "<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/'>"

        'Define body of SOAP with method name and parameter names and vlaues to be passed.
        strEnvelope = strEnvelope & "<soap:Body>"
        strEnvelope = strEnvelope & "<AuthenticateUser xmlns='http://wwwte.abc.com/cpp'>"
        strEnvelope = strEnvelope & "<db>1</db>"
        strEnvelope = strEnvelope & "<_username>MYUSERNAME</_username>"
        strEnvelope = strEnvelope & "<_password>MYPASSWORD</_password>"
        strEnvelope = strEnvelope & "</AuthenticateUser>"
        strEnvelope = strEnvelope & "</soap:Body></soap:Envelope>"    

        'Set properties of HTTP object and send SOAP envelop while calling 'Send' method
        Dim url
        url = "http://cpp.abc.com/cpp/CPPLDAP/CPPLDAP.asmx"
        With objHTTP
            .Open "post", url, False
            .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
            .setRequestHeader "SOAPAction", "http://wwwte.abc.com/cpp/AuthenticateUser"
            .send strEnvelope
        End With
        ' Following will write xml received from web services in the browser
        Dim strResponse
        strResponse = objHTTP.responseXML.Text
        If (strResponse = "") Then
            Response.Write("Invalid user")
        Else        
            Set myXmlDoc = Server.CreateObject("MSXML2.DOMDocument")
            myXmlDoc.loadXML (strResponse)
            Set objLst = myXmlDoc.getElementsByTagName("directoryEntry")
            Set objListNodes = objLst.Context.childNodes(0).childNodes
            For i = 0 To (objListNodes.Length - 1)
               Response.Write(objListNodes.Item(i).nodeName & ":------ " & objListNodes.Item(i).Text)
               Response.Write("</BR>")
            Next
        End If

    %>


    </body>
</html>
  • it is nice to have a complete answer, but please review [this](http://stackoverflow.com/a/11251/443685) warning about Microsoft.XMLHTTP – Saic Siquot Nov 17 '16 at 14:06