Solved

silverlight Asynchronous web service calls

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Read about why website design really matters in today's demanding market.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

861 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