Problem calling web service through VB Script

Author Message
Robbie_RVD

  • Total Posts : 5
  • Scores: 0
  • Reward points : 0
  • Joined: 1/9/2012
  • Status: offline
Problem calling web service through VB Script Monday, January 09, 2012 11:23 AM (permalink)
0
Just trying to call a simple web service using VB Script.

It takes in two parameters but I am getting the error

-2147483638x34 "The data necessary to complete this operation is not yet available"

Any suggestions?


Here is the code sample:
dim objXMLHTTP, strReturn, strEnvelope
strEnvelope = "city=Brisbane&country=Australia"
set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open "POST", "http://www.webservicex.com/globalweather.asmx/GetWeather", True
objXMLHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
objXMLHTTP.Send(strEnvelope)
strReturn = objXMLHTTP.responseText
set objXMLHTTP = Nothing
 
#1
    59cobalt

    • Total Posts : 979
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:Problem calling web service through VB Script Monday, January 09, 2012 11:53 AM (permalink)
    0
    Robbie_RVD
    objXMLHTTP.Open "POST", "http://www.webservicex.com/globalweather.asmx/GetWeather", True
    objXMLHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
    objXMLHTTP.Send(strEnvelope)
    strReturn = objXMLHTTP.responseText
    You made Open() an asynchronous call (3rd parameter is True), but you don't wait for the call to complete. In your case it's probably best to make the call synchronous:
    objXMLHTTP.Open "POST", "http://www.webservicex.com/globalweather.asmx/GetWeather", False

     
    #2
      Robbie_RVD

      • Total Posts : 5
      • Scores: 0
      • Reward points : 0
      • Joined: 1/9/2012
      • Status: offline
      Re:Problem calling web service through VB Script Monday, January 09, 2012 2:47 PM (permalink)
      0
      Thanks for that- am getting closer now.
      I have an XML response like so
      <CurrentWeather><Location>BrisbaneAirport</Location></CurrentWeather>
      Trying to access it like
      oXMLDoc.getElementsByTagName("CurrentWeather")(0).childNodes(0).text
      is giving error 424- Object Required
       
      Can you advise how to pull out the Location value using VBScript?
       
      #3
        59cobalt

        • Total Posts : 979
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:Problem calling web service through VB Script Monday, January 09, 2012 8:40 PM (permalink)
        0
        Where do you instantiate the object oXMLDoc?
         
        #4
          Robbie_RVD

          • Total Posts : 5
          • Scores: 0
          • Reward points : 0
          • Joined: 1/9/2012
          • Status: offline
          Re:Problem calling web service through VB Script Monday, January 09, 2012 9:19 PM (permalink)
          0
          Yep I had that commented out by mistake.
          Now the error is 91 Object variable not set using command:
          dim x
          x = oXMLDoc.documentElement.selectsingleNode("//CurrentWeather")
           
           
           
          #5
            59cobalt

            • Total Posts : 979
            • Scores: 91
            • Reward points : 0
            • Joined: 7/17/2011
            • Status: offline
            Re:Problem calling web service through VB Script Monday, January 09, 2012 10:59 PM (permalink)
            0
            Repeating my question: where do you instantiate the object oXMLDoc?
             
            #6
              Robbie_RVD

              • Total Posts : 5
              • Scores: 0
              • Reward points : 0
              • Joined: 1/9/2012
              • Status: offline
              Re:Problem calling web service through VB Script Tuesday, January 10, 2012 10:45 AM (permalink)
              0
              I instantiate it at the top of the function like so
              dim oXMLDoc, oXMLHTTP
              and then set it with
              set oXMLDoc = CreateObject("MSXML2.DOMDocument")
               
               
               
              #7
                Robbie_RVD

                • Total Posts : 5
                • Scores: 0
                • Reward points : 0
                • Joined: 1/9/2012
                • Status: offline
                Re:Problem calling web service through VB Script Tuesday, January 10, 2012 11:08 AM (permalink)
                0
                I am further with this now- when I dump out the documentElement.XML and use it like so
                oXMLDoc.loadXML("<CurrentWeather> <Location>Brisbane Airport M. O, Australia (YBBN) 27-23S 153-06E 5M</Location> <Time>Jan 09, 2012 - 09:00 PM EST / 2012.01.10 0200 UTC</Time> <Wind> from the ESE (110 degrees) at 15 MPH (13 KT):0</Wind> <Visibility> greater than 7 mile(s):0</Visibility> <SkyConditions> mostly clear</SkyConditions> <Temperature> 86 F (30 C)</Temperature> <DewPoint> 69 F (21 C)</DewPoint> <RelativeHumidity> 58%</RelativeHumidity> <Pressure> 29.74 in. Hg (1007 hPa)</Pressure> <Status>Success</Status> </CurrentWeather>")
                i can successfully pull out the Location node with
                set x = oXMLDoc.documentElement.selectSingleNode("//Location")
                and then write it with
                Response.Write "TEXT IS : " & x.text
                 
                However when I try to retrieve the node using the XML that is already there, I get "ERROR CODE: 0424Object required".
                I wonder what is different as I am simply using the XML which is already there???
                 
                #8
                  59cobalt

                  • Total Posts : 979
                  • Scores: 91
                  • Reward points : 0
                  • Joined: 7/17/2011
                  • Status: offline
                  Re:Problem calling web service through VB Script Tuesday, January 10, 2012 11:46 AM (permalink)
                  0
                  What do you mean by "XML which is already there"? Please post the actual code that is giving you the error.
                   
                  #9

                    Online Bookmarks Sharing: Share/Bookmark

                    Jump to:

                    Current active users

                    There are 0 members and 1 guests.

                    Icon Legend and Permission

                    • New Messages
                    • No New Messages
                    • Hot Topic w/ New Messages
                    • Hot Topic w/o New Messages
                    • Locked w/ New Messages
                    • Locked w/o New Messages
                    • Read Message
                    • Post New Thread
                    • Reply to message
                    • Post New Poll
                    • Submit Vote
                    • Post reward post
                    • Delete my own posts
                    • Delete my own threads
                    • Rate post

                    2000-2012 ASPPlayground.NET Forum Version 3.9