[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

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

0
pankajgharge
Asked:
pankajgharge
  • 5
  • 3
1 Solution
 
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
 
pankajghargeAuthor Commented:
Is there anything wrong in my webServiceUrl? I am not aware of syntaxes in ASP. Please help...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
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
 
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now