-
Jun 5th, 2013, 06:05 PM
#1
Thread Starter
Hyperactive Member
Consuming a web service problem -RESOLVED-
This code which works in VS2005 as a ASP.net Web Client and vb.net app does not work in 2010 Silverlight app.
VS2010 Silverlight says that CourseOutline is undefined.
Furthermore I seem to have new methods such as GetRequest, GetRequestBody, GetResponse, GetResponseBody, and
GetCompletedEventsArgs.
Some of the properties are still there but not CourseOutline. Has it been buried within another property?
Is consuming a service handled differently in Silverlight?
I have the Web Service added as a service reference. Any help would be appreciated. Thanks.
Dim myService As CourseOutline = Nothing
myService = New CourseOutline
Dim myCourseInfo() As CourseVersionInfo = Nothing
Try
myCourseInfo = myService.GetActiveCourses(20137, "ART")
Catch ex As Exception
End Try
Last edited by gtilles; Jul 5th, 2013 at 10:41 AM.
Truly, you have a dizzying intellect.
-
Jun 6th, 2013, 08:59 AM
#2
Re: Consuming a web service problem
Hello,
Silverlight is a subset of the .Net Framework, as a result, some things are available to it.
For instance, System.Data.DataSet does not exist within Silverlight.
It is possible that you are using things within the Web Service that works happily within ASP.Net, but that is not supported in Silverlight.
It this web service currently public that we could take a look at it? If not, is it possible for your to share the method declarations for your Web Service?
Gary
-
Jun 6th, 2013, 10:37 AM
#3
Thread Starter
Hyperactive Member
Re: Consuming a web service problem
The method below is the one I am referring.
As you can see I'm just filling an array made from a custom structure.
<WebMethod()> _
Public Function GetActiveCourses(ByVal pTermID As String, ByVal pDiscipline As String) As CourseVersionInfo()
Dim myStructArray As CourseVersionInfo() = Nothing
Dim myCourseVersions As CourseVersions = Nothing
myCourseVersions = New CourseVersions
myCourseVersions.GetActiveVersions(pTermID, pDiscipline, 0)
Dim myCourseCount As Integer = 0
ReDim myStructArray(myCourseVersions.Count - 1)
Dim myCourseVersion As CourseVersion = Nothing
For Each myCourseVersion In myCourseVersions
myStructArray(myCourseCount).Department = myCourseVersion.Department
myStructArray(myCourseCount).Discipline = myCourseVersion.CourseDiscipline
myStructArray(myCourseCount).CourseID = myCourseVersion.CourseID
myStructArray(myCourseCount).CourseVersionID = myCourseVersion.CourseVersionID
myStructArray(myCourseCount).CourseDiscNbr = myCourseVersion.CourseDisciplineNbr
myStructArray(myCourseCount).CourseKey = myCourseVersion.CourseKey
myStructArray(myCourseCount).CourseTitle = myCourseVersion.CourseDescLong
myStructArray(myCourseCount).TermEffective = myCourseVersion.TermEffective
myStructArray(myCourseCount).TermInactive = myCourseVersion.TermInactive
myCourseCount += 1
Next
myCourseVersion = Nothing
myCourseVersions = Nothing
Return myStructArray
End Function
The service is public but I'd prefer to keep a low profile on it, I'd be happy to PM the URL
Truly, you have a dizzying intellect.
-
Jun 6th, 2013, 01:01 PM
#4
Re: Consuming a web service problem
Could you PM me the details? I don't see anything immediately wrong with the above.
Gary
-
Jun 12th, 2013, 02:43 PM
#5
Re: Consuming a web service problem
Hello,
Sorry for the lack of reply on this, only just now getting a chance to look at this.
Are you aware that in Silverlight, you are not "allowed" to do Synchronous Methods, since this has the potential to lock the UI thread, and this is deemed as "bad practice". As a result, when you generate a service reference for a Silverlight Application, you will not get a method created called GetActiveCourses, instead you are going to get one called GetActiveCoursesAsync. These methods are the same, it is just that one uses a synchronous pattern, and the other uses an asynchronous pattern.
I think that this is at the root of your problem.
Hope that helps!
Gary
-
Jun 27th, 2013, 06:39 PM
#6
Thread Starter
Hyperactive Member
Re: Consuming a web service problem
I do see that now and I have been able to consume the service.
What is still confusing to me is now the function no longer returns a value but I have to rely on the event to fire in order to get my data.
So if I can't return a value from a function then I have to have a private variable for my class and then set the variable value in the event handler.
This seems to work but am I correct in that Web Services in Silverlight no longer return a value except when the event fires (a different sub all together)?
Truly, you have a dizzying intellect.
-
Jun 29th, 2013, 02:30 PM
#7
Re: Consuming a web service problem
Hello,
Within Silverlight the programming model is different. You can't just call a function anymore, and immediately get the response. The method is called Asynchronously, and the response you get back is in the callback method.
Does that make sense?
Gary
-
Jul 4th, 2013, 01:43 PM
#8
Thread Starter
Hyperactive Member
Re: Consuming a web service problem
Yup, It does now.
I've been coding away in Silverlight with my Web Service for several days and it seems to be working well.
Just took awhile to get used to using the event to handle the result instead of a return value from a single function call.
So far so good. Thanks.
Truly, you have a dizzying intellect.
-
Jul 5th, 2013, 02:30 AM
#9
Re: Consuming a web service problem
Glad to hear that you got it working.
If your question has been answered, can you please remember to go back and mark it as resolved?
Thanks
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|