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