J
John Granade
It seems like this should be easy but I must be missing something...I'm
trying to create a web service class that accepts is instantiated with
parameters but I always get just the new() option (parameterless). Here's a
very simple example of what I've tried.
------Web Service----------
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
_
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
Private _text As String
Protected Sub New()
End Sub
Public Sub New(ByVal Text As String)
_text = Text
End Sub
<WebMethod()> _
Public Function GetText() As String
Return _text
End Function
End Class
---------------------------
I added the Protected New sub because I read that you must have one
parameterless constuctor to create a serializable class and it certainly
gives an error if you don't. The above code looks simple enough to me but
when I try to call it in my client it doesn't show a class that can be
created with parameters.
If I add a reference to the web service called 'ws', then in my code when I
try to do somethign like "dim s as New ws.Service1("text")" is says "too
many arguments to 'Public Sub New()' (which I knew because Intellisense
doesn't show any parameters when I typed ws.Service1). But why does it even
see 'Public Sub New()' when I set it to Protected and why doesn't it see
'public sub new (by val text as string)'?
I've been Googling it to death and I can't find anything on this. I see
examples that seem to instantial the web methods with parameters but not
working code. The code above is from a brand new web service project and a
windows client calling it so I don't know how to simplify it any more.
Thanks for any help.
John
John<nospam>@GTSolutions.us
trying to create a web service class that accepts is instantiated with
parameters but I always get just the new() option (parameterless). Here's a
very simple example of what I've tried.
------Web Service----------
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
_
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
Private _text As String
Protected Sub New()
End Sub
Public Sub New(ByVal Text As String)
_text = Text
End Sub
<WebMethod()> _
Public Function GetText() As String
Return _text
End Function
End Class
---------------------------
I added the Protected New sub because I read that you must have one
parameterless constuctor to create a serializable class and it certainly
gives an error if you don't. The above code looks simple enough to me but
when I try to call it in my client it doesn't show a class that can be
created with parameters.
If I add a reference to the web service called 'ws', then in my code when I
try to do somethign like "dim s as New ws.Service1("text")" is says "too
many arguments to 'Public Sub New()' (which I knew because Intellisense
doesn't show any parameters when I typed ws.Service1). But why does it even
see 'Public Sub New()' when I set it to Protected and why doesn't it see
'public sub new (by val text as string)'?
I've been Googling it to death and I can't find anything on this. I see
examples that seem to instantial the web methods with parameters but not
working code. The code above is from a brand new web service project and a
windows client calling it so I don't know how to simplify it any more.
Thanks for any help.
John
John<nospam>@GTSolutions.us