Solved

silverlight Asynchronous web service calls

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Web Development 6 64
Need help with another query 10 50
Read oracle BLOB in vb.net 2 22
why is my slideshow so small on this wordpress site? 7 39
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

738 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