Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2006

Tip: Looking for answers? Try searching our database.

How to invoke webservice from aspx page?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lupakkiotto - 09 Feb 2006 21:46 GMT
Hi! I am a newbye about asp.net and I would like to know where I am wrong
doing this thing...
I have a webservice HelloWorldService.asmx with this code:

<%@ WebService Language="VB" Class="Samples.AspNet.HelloWorldService" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Namespace Samples.AspNet
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class HelloWorldService
Inherits System.Web.Services.WebService
Public pippo As String
<WebMethod()> _
Public Sub HelloWorld(ByVal query As String)
  pippo = query
End Sub
<WebMethod()> _
Public Function Hello() As String
  Return pippo
End Function
End Class
End Namespace

---
Then I have a simple Default3.aspx web page with a button and a textbox.
This is the code:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim xxx As New localhost.HelloWorldService

xxx.HelloWorld("pippone")

TextBox1.Text = xxx.Hello

End Sub

When I click the button I think that webservice is called and then it
returns the string "pippone" in textbox1.. but nothing...
Where I am wrong??
Thanks in advance,
Marco
Robert Wilczynski - 09 Feb 2006 22:12 GMT
Hi,

Web services are stateless meaning that when you call the Hello() function
the value assigned to pippo field no longer exists. A new instance of the
web service is created each time you call a method on the proxy. You should
remove the HelloWorld() method and return the string from the modified Hello()
method and not store it in a field:

<WebMethod()> _
Public Function Hello(ByVal query As String) As String
Return query
End Function

Best regards,
Robert Wilczynski.

> Hi! I am a newbye about asp.net and I would like to know where I am
> wrong
[quoted text clipped - 41 lines]
> Thanks in advance,
> Marco

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.