Solved

silverlight Asynchronous web service calls

Posted on 2010-09-04
7
551 Views
Last Modified: 2013-11-19
I am trying to call two web service at the same time. I read that I need to use the user state object. Below is my code. Every time I execute them only one returns. The other service returns the error message " an exception occurred during the operation making the result set invalid"

What do I need to change to get these calls to work correctly. Thank you in advance.
Public Sub logoncommands()
        UserInformation.ReturnUserFullNameAsync(Guid.NewGuid)
        UserInformation.ReturnRoleIDAsync(Guid.NewGuid)
    End Sub

 Private Sub UserNameReturned(ByVal sender As Object, ByVal e As UserInfo.ReturnUserFullNameCompletedEventArgs) Handles UserInformation.ReturnUserFullNameCompleted
        Dim g As Guid = e.UserState
        Me.lbl_username.Content = Format("Welcome {0}", e.Result.ToString)
    End Sub

Open in new window

0
Comment
Question by:jimseiwert
  • 2
  • 2
7 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 33611082
You have called the web service but the code to callback are missing for both the calls.

for eg. for the method, UserInformation.ReturnUserFullNameAsync, you should see "UserInformation.ReturnUserFullNameCompleted" event.  Add a event handler to this call back method. The same way you have to do for other also.
0
 
LVL 2

Author Comment

by:jimseiwert
ID: 33611500
I do have the call backs for the code. I gave one example of the call back up there UserNameReturned is for UserInformation.ReturnUserFullNameCompleted

I did not put the other one as I was just showing example of how I am handiling tyhe callback. I am still tying to figure out how to call both webservices at the same time without getting the error message " an exception occurred during the operation making the result set invalid".
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 33675420
looks like your service is throwing an exp.. this code will put that exp in username label
Private Sub UserNameReturned(ByVal sender As Object, ByVal e As UserInfo.ReturnUserFullNameCompletedEventArgs) Handles UserInformation.ReturnUserFullNameCompleted
        If IsNothing(e.Error) Then
            Me.lbl_username.Content = Format("Welcome {0}", e.Result.ToString)
        Else
            Dim exp As Exception = e.Error

            While IsNothing(exp) <> True
                Me.lbl_username.Content += exp.Message + "\r\n"
                exp = exp.InnerException
            End While
        End If
    End Sub

Open in new window

0
 
LVL 2

Author Comment

by:jimseiwert
ID: 33686784
Correct. I get an error when I call two web services at the same time so if I call service 1 and service 2 before service 1 fails then I get the error. I am trying to find a way to call both services at the same time.

Acording to microsoft I have to pass it a user state object to do this. I tried using GUID as the object but that did not work.
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 33693818
can you debug and see what error your service is throwing.. the code i posted will help you. also are you using FaultException in the server side so that the errors are propagated to the client ?
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

770 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