VoiceGuide: How can VG retrieve info from a Web Service - VoiceGuide

Jump to content

Page 1 of 1
  • Login to start a new topic
  • You cannot reply to this topic

How can VG retrieve info from a Web Service example for using Web Services provided

#1 Guest_Karl Kraus_*

  • Group: Guests

Posted 06 January 2005 - 11:12 AM

I need to have Voiceguide get a zipcode from the caller and pass it to a webservice then text to speech all of the responses.

Karl

#2 User is offline   SupportTeam Icon

  • Group: Admin
  • Posts: 13,474
  • Joined: 30-January 03

Posted 06 January 2005 - 11:32 AM

Pretty easy to do from within a 'Run VBScript' module.

Can we access the webservice?

Can you give us some examples of what the webservice would return?

#3 User is offline   krauskarl Icon

  • Group: Members
  • Posts: 3
  • Joined: 06-January 05

Posted 06 January 2005 - 11:44 AM

Yes. Can you email me and I will give you the url where you can see the parms.

Karl

#4 User is offline   krauskarl Icon

  • Group: Members
  • Posts: 3
  • Joined: 06-January 05

Posted 06 January 2005 - 01:01 PM

krauskarl@hotmail.com

#5 User is offline   SupportTeam Icon

  • Group: Admin
  • Posts: 13,474
  • Joined: 30-January 03

Posted 06 January 2005 - 01:10 PM

Email sent...
(our email address is: support@voiceguide.com)

#6 Guest_Dave L_*

  • Group: Guests

Posted 07 January 2005 - 01:58 AM

Can you please publish example codes to do web services using 'Run VBScript' module?

Thanks

#7 User is offline   SupportTeam Icon

  • Group: Admin
  • Posts: 13,474
  • Joined: 30-January 03

Posted 07 January 2005 - 03:50 PM

Here is an example of how to retrieve information from a web service and return it to VoiceGuide.

The example queries a (free) web service provided by ejse.com and retrieves the weather information for a particular ZIP code. In this example 22207 (Arlington, VA) was used.

Returned data is then formatted as a Result Variable list and returned to VoiceGuide, when it may now be spoken to the caller or used for any further processing you may like.

The demo now calls MsgBox function to show the user what was retrieved as well.

You must have Microsoft's SOAP 3.0 Toolkit installed to use this.
See: http://msdn.microsof...ds/default.aspx

The code below would go straight into a Run VBScript module:
CODE
Set soapClient = CreateObject("MSSOAP.SoapClient30")
soapClient.MSSoapInit "http://www.ejse.com/WeatherService/Service.asmx?WSDL"
Set node_list = soapClient.GetWeatherInfo(22207)
       
For Each node In node_list
  sText = sText & "[" & node.nodeName & "]{" & node.Text & "}"
Next

'show user the returned information.
'comment out this line later.
MsgBox sText 

set vg = CreateObject("VoiceGuide.CommandLink")
vg.Run_ResultReturn $RV_LINEID, sText
set vg = Nothing

set soapClient = Nothing
set node_list = Nothing


an example of the Result Variable list returned:

[Location]{Arlington, VA}[IconIndex]{26}[Temprature]{44°F}[FeelsLike]{41°F}[Forecast]{Cloudy}[Visibili
y]{9.0 miles}[Pressure]{29.93 inches and rising}[DewPoint]{41°F}[UVIndex]{0 Low}[Humidity]{89%}[Wind]{From the North Northwest at 6 mph}[ReportedAt]{}[LastUpdated]{}


So for example to say to the caller that wind is "From the North Northwest at 6 mph" you would just ask VoiceGuide to TTS the contents of $RV[Wind]

And of course you can replace 22207 with a Result Variable which stores the ZIP code entered by the caller in some previous 'Get Numbers' module, or retrieved from a database etc etc...

#8 User is offline   krauskarl Icon

  • Group: Members
  • Posts: 3
  • Joined: 06-January 05

Posted 07 January 2005 - 03:58 PM

Thank you so very much. I will try this out and let you know how it goes!

Karl

#9 User is offline   SupportTeam Icon

  • Group: Admin
  • Posts: 13,474
  • Joined: 30-January 03

Posted 14 January 2005 - 07:00 PM

If you do not want to use the SOAP toolkit then another approach to retrieve data from the above Web Service would be to just retrieve the contents returned by this URL:

http://www.ejse.com/...o?zipCode=22207

and then just parse the returned XML to extract the required data. Similar approach would also work for all other Web Services.

#10 User is offline   JBeck Icon

  • Group: Members
  • Posts: 5
  • Joined: 14-April 05

Posted 03 May 2005 - 11:53 AM

I wanted to implement this by just parsing the XML. Feel free to use it anyone, it works well on my system.

CODE
' set xmlDoc=CreateObject("Microsoft.XMLDOM")
' Dim xDoc As MSXML.DOMDocument
' Dim Nodes As MSXML.IXMLDOMNodeList

set vg = CreateObject("VoiceGuide.CommandLink")

Dim MyTime
MyTime = Time  ' Return current system time.
vg.RvSet $RV_LINEID, "SysTime", MyTime

Set xDoc = CreateObject("MSXML2.DOMDocument")
xDoc.async = False
xDoc.validateOnParse = False

If xDoc.Load("http://www.ejse.com/WeatherService/Service.asmx/GetWeatherInfo?zipCode=34236") Then
 ' The document loaded successfully.

  resultStr = "The temperature is currently " & _
  left(xDoc.getElementsByTagName("Temprature").item(0).text,len(xDoc.getElementsByTagName("Temprature").item(0).text)-2) _
  & ".  Humidity is " & xDoc.getElementsByTagName("Humidity").item(0).text & _
  ".  The dew point is " & _
  left(xDoc.getElementsByTagName("DewPoint").item(0).text,len(xDoc.getElementsByTagName("DewPoint").item(0).text)-2) _
  & ".  It feels like " & _
  left(xDoc.getElementsByTagName("FeelsLike").item(0).text,len(xDoc.getElementsByTagName("FeelsLike").item(0).text)-2) _
  & ".  The wind is " & _
  left(xDoc.getElementsByTagName("Wind").item(0).text,len(xDoc.getElementsByTagName("Wind").item(0).text)-3) _
  & "miles per hour.  Today's forecast is " & xDoc.getElementsByTagName("Forecast").item(0).text & "."
 
  vg.RvSet $RV_LINEID, "WeatherStr", resultStr
  vg.Run_ResultReturn $RV_LINEID, True
Else
  ' The document failed to load.

  Set xPE = xDoc.parseError
  With xPE
     strErrText = "Your XML Document failed to load" & _
       "due the following error." & vbCrLf & _
       "Error #: " & .errorCode & ": " & xPE.reason & _
       "Line #: " & .Line & vbCrLf & _
       "Line Position: " & .linepos & vbCrLf & _
       "Position In File: " & .filepos & vbCrLf & _
       "Source Text: " & .srcText & vbCrLf & _
       "Document URL: " & .url
    End With
    
    vg.RvSet $RV_LINEID, "WeatherStr", strErrText
    vg.Run_ResultReturn $RV_LINEID, False
    
    Set xPE = Nothing
End If

Set vg = Nothing
Set xDoc = Nothing
Set Nodes = Nothing
Set MyTime = Nothing


Just add a speak module and put $RV[WeatherStr] in the text-to-speak box. Have it play a music file while the script runs as I've found sometimes there's a delay, possibly from the www.ejse.com site.

p.s. voiceguide rocks.

#11 User is offline   SupportTeam Icon

  • Group: Admin
  • Posts: 13,474
  • Joined: 30-January 03

Posted 03 May 2005 - 01:19 PM

www.ejse.com does sometimes delay before returning information.
It is easy to confirm where the delays are - just use a few Admin_TraceLogAdd() functions in your VBScript and then examine the VG Debug Trace.

http://www.voiceguid...TraceLogAdd.htm

Page 1 of 1
  • Login to start a new topic
  • You cannot reply to this topic