Solved

VB6 - Call WebService

Posted on 2014-03-18
5
538 Views
Last Modified: 2014-03-24
Good Day Experts!

I am challenged today with 1) working in VB6 and 2) running a WebService

I have looked around on the net how to call a WebService but I am not sure what is needed since I have never done this before.  

The WebService takes in a start currency and a converted to currency.  

http://www.webservicex.net/CurrencyConvertor.asmx?op=ConversionRate

Can you help with references that may help me achieve this and give back the exchange rate?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
  • 3
  • 2
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39939779
according to the above output, you don't need to do anything special, as you are allowed to do a plain http get version:
http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=EUR
which returns this (xml):
<double>0.7189</double>

which would be as simple as this:
Dim obj As MSXML2.ServerXMLHTTP
Set obj = New MSXML2.ServerXMLHTTP
obj.open "GET", "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=EUR"
obj.send

If obj.Status >= 400 And obj.Status <= 599 Then
  Debug.Print "Error Occurred : " & obj.Status & " - " & obj.statusText
Else
  Debug.Print obj.ResponseText
End If 

Open in new window


the webservice methods are a bit more complex, but why if you have the simple version :)
0
 

Author Comment

by:Jimbo99999
ID: 39946205
Thanks you for the help.  There have been sooo many projects here.  I will get back to this one on Monday.

Much appreciated,
jimbo99999
0
 

Author Comment

by:Jimbo99999
ID: 39950512
Good Day!

When I try this, I am gertting an error message "Compile error: User-defined type not defined".  It appears to not like the line "Dim obj as MSXXML2.ServerXMLHTTP"

Do I need ot make a proprerty setting or add anything somewhere in the project?

Thanks,
jimbo99999
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39950541
you have to add the XML in the Project references... not sure any more how it was called, but someing like "MS XML 3.0" or "... 4.0" ...
0
 

Author Comment

by:Jimbo99999
ID: 39950565
I made a little adjustment and it is working now!

Set obj = CreateObject("MSXML2.ServerXMLHTTP")

This is great...now just have to parse out the answere from the Response.Text.

Thanks for the help,
jimbo9999
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 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