pankajgharge
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>
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("MSXML 2.ServerXM LHTTP")
httpReq.Open "GET", webServiceUrl, False
httpReq.Send
Set myXmlDoc =Server.CreateObject("MSXM L.DOMDocum ent")
myXmlDoc.load(httpReq.resp onseBody)
Set httpReq = Nothing
Set objLst = myxmlDoc.getElementsByTagN ame("*")
If objLst is Nothing Then
Response.Write("There are no Nodes")
Else
Response.Write("There are nodes")
Response.Write("</BR>Numbe r of nodes in response:" & objLst.length)
'For i = 0 to (objLst.length-1)
'Response.Write(CStr(objLs t.item(i). nodeName))
'Next
End If
'Set node = myXmlDoc.documentElement.s electSingl eNode("//f ullname")
'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(consumeWeb Service)
%>
</body>
</html>
<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("MSXML
httpReq.Open "GET", webServiceUrl, False
httpReq.Send
Set myXmlDoc =Server.CreateObject("MSXM
myXmlDoc.load(httpReq.resp
Set httpReq = Nothing
Set objLst = myxmlDoc.getElementsByTagN
If objLst is Nothing Then
Response.Write("There are no Nodes")
Else
Response.Write("There are nodes")
Response.Write("</BR>Numbe
'For i = 0 to (objLst.length-1)
'Response.Write(CStr(objLs
'Next
End If
'Set node = myXmlDoc.documentElement.s
'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(consumeWeb
%>
</body>
</html>
ASKER
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.
ASKER
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...
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...
ASKER
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("MSSOA P.SoapClie nt")
oSOAP.ClientProperty("Serv erHTTPRequ est") = True
oSOAP.mssoapinit("http://cpp.cisco.com/cpp/CPPLDAP/CPPLDAP.asmx?wsdl")
Set objDOMDoc = Server.CreateObject("Msxml 2.DOMDocum ent.4.0")
objResponse = objDOMDoc.loadXML(CStr(oSO AP.Authent icateCisco User(1,"MY USERNAME", "MYPASSWOR D")))
Response.Write(objResponse )
%>
</body>
</html>
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("MSSOA
oSOAP.ClientProperty("Serv
oSOAP.mssoapinit("http://cpp.cisco.com/cpp/CPPLDAP/CPPLDAP.asmx?wsdl")
Set objDOMDoc = Server.CreateObject("Msxml
objResponse = objDOMDoc.loadXML(CStr(oSO
Response.Write(objResponse
%>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
Try setting ASYNC to true.