Register  Login
Forums

 (you must be logged in to post)

Subject: How to call a WebService in VB?
Prev Next
You are not authorized to post a reply.

Author Messages
Dario RossaUser is Offline

Posts:11


05/21/2008 11:23 PM  
Hi,

How can I make a call to my web service using VB? In my WebService.vb I have:

<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function

But in page.xaml.vb I can call this:

Private Sub GetMyData()
Dim proxy As New WebServiceSoapClient()
Dim MyEndpointAddress As EndpointAddress
MyEndpointAddress = New EndpointAddress(strWebServiceURL)
proxy.Endpoint.Address = MyEndpointAddress
proxy.HelloWorldAsync()
End Sub

But not this

Sub HelloWorld_Completed(ByRef sender As Object, _
ByVal e As HelloWorldCompletedEventArgs) _
Handles proxy.HelloWorldCompleted
'Retrieve my data here
End Sub

Because proxy requires a WithEvents variable declared in the base class. How do I proceed? Thank you.

Best regards,
Dario Rossa
Michael Washington (admin)User is Offline

Posts:52


05/22/2008 5:19 AM  
I have not tried it in VB so I don't know. Anyone?
Dario RossaUser is Offline

Posts:11


05/22/2008 6:01 AM  
Hi Michael,

I think I solved it using in page.xaml.vb:

Private Sub GetData(ByVal PortalID As Integer)
Dim proxy As New WebServiceSoapClient()
Dim MyEndpointAddress As EndpointAddress
MyEndpointAddress = New EndpointAddress(strWebServiceURL)
proxy.Endpoint.Address = MyEndpointAddress
AddHandler proxy.HelloWorldCompleted, AddressOf _
HelloWorld_Completed
proxy.HelloWorldAsync()
End Sub

Sub HelloWorld_Completed(ByVal sender As Object, _
ByVal e As HelloWorldCompletedEventArgs)
' Gather data here
End Sub

But now I receive an unknown error, so I am trying to configure my Silverlight runtime to use satellite debug libraries, at least to know what's wrong! I will keep you informed.

Best regards,
Dario Rossa
Dario RossaUser is Offline

Posts:11


05/22/2008 8:41 AM  
Hi Michael,

after some testing the above code works just perfect in VB, the unknown error was caused by an error in another file. The optional debug assemblies still linger, but this is a known issue, so I hope it will be fixed in future releases.

Best regards,
Dario Rossa.
Michael Washington (admin)User is Offline

Posts:52


05/22/2008 8:46 AM  
That is great. Also, if anyone wants to make VB versions of any of my examples I'll post them. Thanks.
Dario RossaUser is Offline

Posts:11


06/10/2008 12:51 AM  
Hi All,

Note that the previous code will no longer work after upgrading from Silverlight Beta 1 to Beta 2. I love working with betas!:mad:

Best regards,
Dario Rossa
You are not authorized to post a reply.
Forums > DNN Silverlight Forum > Silverlight and DotNetNuke > How to call a WebService in VB?



ActiveForums 3.7
Terms Of Use | Privacy Statement | Copyright 2007-2008 by Adefwebserver.com Dynnamite DotNetNuke Skins & Modules