PDA

Click to See Complete Forum and Search --> : Using a Web Service in Silverlight 3 and VB.net 2008


samo8076
Jan 12th, 2010, 07:02 AM
Hi guys,

Im using Silver light 3 in vb.net Visual Studio 2008.

My web service had simply test functions a the moment including the standard 'Hello World' function.
I have referenced the web service no problem in Silver light but im really stuck how to return my 'hello world' function. Iv seen various examples on the net but im really stuck as to how to use them as the are in c#

here is my code iv got so far.....

Dim t As New ColonySL.ServiceReference1.ColonySLSoapClient
t.HelloWorldAsync()

but whatever i try will not return the simple 'hello world' string

had anybody got a simple example in vb?

Thanks

peteshir
Feb 4th, 2010, 02:42 PM
Try putting a control such as a TextBlock on your form. We can call it txt1 if you want.

Have to add a new procedure, We can call it "t_Completed. This is what the procedure should look like:

Public sub t_Completed(ByVal sender As Object, ByVal e As t.Hello_WorldCompletedEventArgs)
txt1.text=e.Result
end sub

Now we need an event handler to handle the completed event. After the line it should look like this:

Dim t As New ColonySL.ServiceReference1.ColonySLSoapClient
t.HelloWorldAsync()
AddHandler t.Hello_WorldCompleted, AddressOf t_Completed

Now you can call your service with a

t.Hello_World()

When this is done you will see "Hello World" in your textbox.

I hope this works