Consuming web service in classic ASP

Posted on 2009-04-15
Last Modified: 2012-05-06
I am new to classic ASP. What is wrong in bellow code.
The code prints "Document not Loaded"






    Dim webServiceUrl, httpReq, node, myXmlDoc

    webServiceUrl = "!"

    'webServiceUrl = ""


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


    httpReq.Open "GET", webServiceUrl, False 



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

    if myXmlDoc.load(httpReq.responseBody) Then

       Response.write("document loaded")


       Response.write("document not loaded")

    end If


    Set httpReq = Nothing 

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



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


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

    'End If    






Open in new window

Question by:pankajgharge

Accepted Solution

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:


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.

Author Comment

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.

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: and…
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