Link to home
Start Free TrialLog in
Avatar of pankajgharge
pankajghargeFlag for India

asked on

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

Avatar of JoachimMartinsen
JoachimMartinsen
Flag of Norway image

What does your error message say?

Try setting ASYNC to true.
Avatar of pankajgharge

ASKER

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>

Is there anything wrong in my webServiceUrl? I am not aware of syntaxes in ASP. Please help...
It depends on what the webServiceUrl returns. It could be that it doesn't return a valid xml for the MSXML.DOMDocument to load.
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...
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>
ASKER CERTIFIED SOLUTION
Avatar of JoachimMartinsen
JoachimMartinsen
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.