Consuming webservice in classic ASP

What could be wrong in following .ASP page. I am new to classic ASP. How can I get the response from webservice?
<html>
<head>
<title></title>
</head>
<body>
 
<%  
 
Dim SoapRequest
Set SoapRequest = CreateObject("MSXML2.XMLHTTP")
 
Dim myXML, webServiceUrl
Set myXML = CreateObject("MSXML.DOMDocument")
myXML.Async=False
webServiceUrl = "http://cpp.cisco.com/cpp/CPPLDAP/CPPLDAP.asmx/AuthenticateCiscoUser?db=1&_username=MYUSERNAME&_password=MYPASSWORD"
SoapRequest.Open "POST", webServiceUrl, False
SoapRequest.setRequestHeader "Content-Type","text/xml;charset=utf-8"
SoapRequest.setRequestHeader "SOAPAction", """http://wwwte.cisco.com/cpp/AuthenticateCiscoUser"""
SoapRequest.Send
 
If myXML.load(SoapRequest.responseXML) Then    
    'Dim Node
    'Set Node = myXML.documentElement.selectSingleNode("//Result")     
     Response.write("Loaded")   
    Set Node = Nothing
Else
    Response.Write("Not loaded")
End If
 
Set SoapRequest = Nothing
Set myXML = Nothing
 
         
%>
 
</body>
</html>

Open in new window

LVL 1
pankajghargeAsked:
Who is Participating?
 
JoachimMartinsenCommented:
Well, if the webServiceUrl generates a valid xml, you could load the url directly into MSXML.DOMDocument.

I can't really see why the MSXML2.ServerXMLHTTP would be necessary in this case.
0
 
JoachimMartinsenCommented:
What does your error message say?

Try setting ASYNC to true.
0
 
pankajghargeAuthor Commented:
It displays Not Loaded so I have modified code as follows. Still I am not getting response from webservice.

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

<%    

    Dim webServiceUrl, httpReq, node, myXmlDoc    

    webServiceUrl = "http://cpp.cisco.com/cpp/CPPLDAP/CPPLDAP.asmx/AuthenticateCiscoUser?db=1&_username=MyUsername&_password=MyPassword"
    Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
   
    httpReq.Open "GET", webServiceUrl, False
    httpReq.Send
   
    Set myXmlDoc =Server.CreateObject("MSXML.DOMDocument")
    myXmlDoc.load(httpReq.responseBody)
   
    Set httpReq = Nothing
   
    Set objLst = myxmlDoc.getElementsByTagName("*")
    If objLst is Nothing Then
       Response.Write("There are no Nodes")
    Else
       Response.Write("There are nodes")
       Response.Write("</BR>Number of nodes in response:" & objLst.length)
       'For i = 0 to (objLst.length-1)
          'Response.Write(CStr(objLst.item(i).nodeName))
       'Next
    End If

   
    'Set node = myXmlDoc.documentElement.selectSingleNode("//fullname")
    'If Not node Is Nothing Then
        'consumeWebService = "<b>No User present in AD</b><font color = blue>" & node.text & "</font>"
         
    'Else
        'consumeWebService = "<b>User is present in AD</b>"
       
    'End If  
         
    'Response.write(consumeWebService)
       
%>

</body>
</html>

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
pankajghargeAuthor Commented:
Is there anything wrong in my webServiceUrl? I am not aware of syntaxes in ASP. Please help...
0
 
JoachimMartinsenCommented:
It depends on what the webServiceUrl returns. It could be that it doesn't return a valid xml for the MSXML.DOMDocument to load.
0
 
pankajghargeAuthor Commented:
Thanks for reply,
Are you sure that the code, I have written is proper and right? If so, I can ask my client to look at the web service...
0
 
pankajghargeAuthor Commented:
Hello,
The same web service is working locally when I put the following code in .asp file on my machine.
But it does not work on Server. Server is Windows Server 2003 and we have installed MS SOAP Toolkit there. Please suggest...
Here is a code:

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

<%        

       Dim oSOAP      
         Dim objDOMDoc
         Dim objResponse
         Set oSOAP = Server.CreateObject("MSSOAP.SoapClient")
         oSOAP.ClientProperty("ServerHTTPRequest") = True
         oSOAP.mssoapinit("http://cpp.cisco.com/cpp/CPPLDAP/CPPLDAP.asmx?wsdl")    
         Set objDOMDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
         objResponse = objDOMDoc.loadXML(CStr(oSOAP.AuthenticateCiscoUser(1,"MYUSERNAME","MYPASSWORD")))
         Response.Write(objResponse)    
         
%>

</body>
</html>
0
 
pankajghargeAuthor Commented:
Yes,  Code is working fine on my machine but not working on Windows Server 2003.
On my machine I have mssoap1.dll and wisc10.dll at C:\Program Files\Common Files\MSSoap\Binaries
On Windows server 2003 those libraries are not present so code fails. We have installed MS SOAP Toolkit but code did not work.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.