?
Solved

return value async webservice

Posted on 2014-12-11
9
Medium Priority
?
126 Views
Last Modified: 2015-01-16
Does anyone have a good example of calling a web service asynchronously and retrieving a return value (i.e. a dataset) in ASP.NET And VB.NET ?
0
Comment
Question by:cehrnow
[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
  • 5
  • 4
9 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40496641
Introductory questions:

What type of web service?

What type of web site?

Framework version?
0
 

Author Comment

by:cehrnow
ID: 40496856
ASMX
Framework 4.0
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40497306
If you are going against a classic .asmx web service, then it should have auto-generated async methods in the proxy that it generated, so you could do something like this:

 	 Private supplier As New BookSupplier.WebService()

        Public Sub GetBookCost(ByVal bookName As String)

	   AddHandler supplier.GetCostCompleted AddressOf supplier_GetCostCompleted

	   supplier.GetCostAsync(bookName)

        End Sub

       Private Sub supplier1_GetCostCompleted(sender As Object, e As BookSupplier.GetCostCompletedEventArgs)
	   If e.Error IsNot Nothing Then
		Throw e.Error
	   End If
    	   Dim cost As Decimal = TryCast(e.UserState, Decimal)
	   costLabel.Text = "Quote from Book Supplier: " & cost
        End Sub

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:cehrnow
ID: 40497670
They did not get auto generated as I think this is not longer the default.
Can you please show what I need to add.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40500413
Can you show me the code for the auto-generated proxy?

How did you add the web service reference?
0
 

Author Comment

by:cehrnow
ID: 40500642
I don't think VS2013 adds these anymore ?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40501021
Here is an example of a classic web service reference:

     public void EchoMessageServiceAsync(string MessageID, string Destination, string Touchpoint, string Location, string Style, string ProductionFlag) {
            this.EchoMessageServiceAsync(MessageID, Destination, Touchpoint, Location, Style, ProductionFlag, null);
        }
       
        /// <remarks/>
        public void EchoMessageServiceAsync(string MessageID, string Destination, string Touchpoint, string Location, string Style, string ProductionFlag, object userState) {
            if ((this.EchoMessageServiceOperationCompleted == null)) {
                this.EchoMessageServiceOperationCompleted = new System.Threading.SendOrPostCallback(this.OnEchoMessageServiceOperationCompleted);
            }

Use the following steps:

Right click on the Reference node in the Server Explorer tree
Select Add Service Reference
Click on the Advanced button in the lower left corner
Click on the Add Web Reference button in the Compatibility section at the bottom of the Advanced dialog

This will allow you to add a web service reference the old, classic way.
0
 

Author Comment

by:cehrnow
ID: 40502155
It is the async methods in the webservice that are not being created.
Do you have VB code to show how these can be added ?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 40503006
Even in Visual Basic, the async methods should be created when you add a classic web reference, using the Compatibility dialog.

I have uploaded a short .mp4 recording of what I mean.

https://filedb.experts-exchange.com/incoming/ee-stuff/8399-Add-Classic-Web-Reference.mp4
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

801 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