Call a webservice from vb.net

Can someone show me the code to call this webservice from vb.net?

 http://www.ripedev.com/webservices/LocalTime.asmx?WSDL

In a windows app.  I just add it as a service Reference in Visual Studio 2015.  I have a button and a textbox.  But I can't seem to find the right code.  Any suggestions.
LVL 2
bergertimeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

louisfrCommented:
After referencing the webservice and setting its name to "LocalTime", I wrote this code:
Dim client As New LocalTime.LocalTimeSoapClient
Dim time = client.LocalTimeByZipCode("4000")

Open in new window

but it gets me the following error:
Server was unable to process request.
 ---> Unable to connect to server ds041167.mongolab.com:41167: Invalid credential for database 'zipcode'..
 ---> Invalid credential for database 'zipcode'.
 ---> Command 'authenticate' failed: auth failed (response: { "ok" : 0.0, "errmsg" : "auth failed", "code" : 18 })

Open in new window

0
bergertimeAuthor Commented:
Dim time = client.LocalTimeByZipCode("4000")

When I use this line, I can't use "LocalTimeByZipCode"  the only thing I get is LocalTimeByZipCodeAsyc
0
louisfrCommented:
I can call both LocalTimeByZipCode and LocalTimeByZipCodeAsync. When calling the async version and waiting for the result, I get the same error.
Maybe you need some kind of authentification.

I tried the same way to call http://www.webservicex.net/CurrencyConvertor.asmx?WSDL and got better results.
Dim client As New CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap")
Dim rate = client.ConversionRate(CurrencyConvertor.Currency.EUR, CurrencyConvertor.Currency.USD)

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

bergertimeAuthor Commented:
Here is what I get.

New-Bitmap-Image.bmp
0
bergertimeAuthor Commented:
I added the webservice http://www.webservicex.net/CurrencyConvertor.asmx?WSDL what am I missing?
0
louisfrCommented:
In the Solution Explorer window, right-click on ServiceReference2 and select "Object Browser".
It should open on the ServiceReference2 namespace. Expand it, and click on the CurrencyConvertorSoap interface. Check which methods appear in the right panel.
0
bergertimeAuthor Commented:
Like this?

screen.jpg
0
louisfrCommented:
I didn't look at the project type before. I see it's "Universal Windows". It looks like that kind of project doesn't allow synchronous calls to web services.

Anyway, you can use the asynchronous call:
Dim client As New CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap")
Dim task = client.ConversionRate(CurrencyConvertor.Currency.EUR, CurrencyConvertor.Currency.USD)
Dim rate = task.Result

Open in new window

The last line makes it wait for the asynchronous call to complete.
0
bergertimeAuthor Commented:
Where do I put the amount to be converted?
0
bergertimeAuthor Commented:
I want to convert 100 EUR to USD.
0
louisfrCommented:
That function returns the rate. You multiply it by the amount.
I call the method with FromCurrency = EUR and ToCurrency = USD. I get 1.0773.
100 EUR * 1.0773 = 107.73 USD
0
bergertimeAuthor Commented:
I'm sorry, I'm just not getting this to work.  Using Universal Apps, I add the service.  I copy and paste the code you posted and here is what I get.Capture.JPG
0
louisfrCommented:
Sorry, I mistyped the method name. It should be:
Dim client As New CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap")
Dim task = client.ConversionRateAsync(CurrencyConvertor.Currency.EUR, CurrencyConvertor.Currency.USD)
Dim rate = task.Result

Dim euros = 100
Dim dollars = euros * rate

Open in new window

0
bergertimeAuthor Commented:
Still getting an error, see below.

Capture.JPG
0
bergertimeAuthor Commented:
Ok, I change the first line to:

Dim client As New CurrencyConvertor.CurrencyConvertorSoapClient()

From this:

Dim client As New CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap")

What was the "CurrencyConvertorSoap" for?  

But the good news is it's working.  Yippie!!!   Thanks!!
0
louisfrCommented:
I can't remember what the parameter is supposed to be.
Glad you made it work.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bergertimeAuthor Commented:
Thank you so much.
0
bergertimeAuthor Commented:
Hey, I asked this question too, http://www.experts-exchange.com/questions/28750779/VB-net-and-soap.html#a41059768

any chance you could help, I'm not making any progress?  Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.