Solved

Consuming web service in classic ASP

Posted on 2009-04-15
2
330 Views
Last Modified: 2012-05-06
Hello,
I am new to classic ASP. What is wrong in bellow code.
The code prints "Document not Loaded"
<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!"

    'webServiceUrl = "http://teachatechie.com/GJTTWebServices/ZipCode.asmx/GetLocation?ZipCode=32218"

    

    Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP") 

    

    httpReq.Open "GET", webServiceUrl, False 

    httpReq.Send 

    

    Set myXmlDoc =Server.CreateObject("MSXML.DOMDocument")	
 

    if myXmlDoc.load(httpReq.responseBody) Then

       Response.write("document loaded")
 

    else

       Response.write("document not loaded")

    end If

    

    Set httpReq = Nothing 

    'title = myXmlDoc.documentElement.ChildNodes(1).text

    'Response.write(title)

    

    'Set node = myXmlDoc.documentElement.selectSingleNode("//CITYSTNAME") 

    

    'If Not node Is Nothing Then 

        'consumeWebService = "<b>That zipcode is within this city:</b><font color = blue>" & node.text & "</font>" 
 

    'Else 

        'consumeWebService = "<b>There is no location associated with that zipcode.</b>" 
 

    'End If    

'Response.Write(consumeWebService)

         

%>
 

</body>

</html>

Open in new window

0
Comment
Question by:pankajgharge
2 Comments
 
LVL 6

Accepted Solution

by:
JoachimMartinsen earned 20 total points
Comment Utility
The .responseBody returns text. And the myXmlDoc.load requires a file to be loaded, not plain text.

If the webServiceUrl url is directing to an xml file, try loading this directly into myXmlDoc.load without using MSXML2.ServerXMLHTTP. Like this:

myXmlDoc.load(webServiceUrl)

Another way is to save the text into an temporary xml file and then to load it to the myXmlDoc.load.

Hope this makes sense.
0
 
LVL 1

Author Comment

by:pankajgharge
Comment Utility
Thanks, JoachimMartinsen
The document is loaded no issues.
But how can I catch a response of webservice. Its a authentication webservice and I need true or false in response.
I am very very new to asp page.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now