Solved

VB6 - Call WebService

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 102
SSRS expression Issue finding a string 10 65
How to Add / Edit Windows Menu 4 50
Added a column screws up code 5 47
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

919 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

14 Experts available now in Live!

Get 1:1 Help Now