Solved

silverlight Asynchronous web service calls

Posted on 2010-09-04
7
549 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

757 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

21 Experts available now in Live!

Get 1:1 Help Now