?
Solved

VB6 - Call WebService

Posted on 2014-03-18
5
Medium Priority
?
596 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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 143

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

800 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