Solved

VB6 - Call WebService

Posted on 2014-03-18
5
518 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

705 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

19 Experts available now in Live!

Get 1:1 Help Now