Solved

silverlight Asynchronous web service calls

Posted on 2010-09-04
7
555 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
[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
  • 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

717 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