Re: Can't provide constructor parameters

Tech-Archive recommends: Fix windows errors by optimizing your registry



The Web Service isn't REALLY a class. .NET just uses the class mechanism to make it easy for us to create them. But the web service standard has no knowledge of what we are doing and is really just letting us call the individual methods in them. You'll notice there isn't any ability to call a property either.

What we create as an object on the client side is just a proxy to call the web service. All the web service or the client knows about really are the methods in our class that we've marked with the "WebMethod" attribute and are public.

Dave Bush
http://blog.dmbcllc.com

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.BasicPr
ofile1_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


.



Relevant Pages

  • Re: Reflection.Emit a dynamic assembly to a static member
    ... client sends an invalid string. ... This way the client cannot will not be able ... because that would break the web service clients. ... I suggest that your web method accepts a string parameter ...
    (microsoft.public.dotnet.languages.csharp)
  • Can Web Service modify SOAP Header parameters?
    ... I built a test web service project in VS2005 and I'm tring to ... Public Username as String ... client is able to populate grid with received dataset ... I thought that most logical place to have tokens located is a SOAP ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Creating A log File for Web Services?
    ... Private m_appfolder As String ... This means that the log file is located where you want it. ... > know how to find the path of a web service .DLL so I can fix this code to ... > Public Sub COMMON_Module_Print(ByVal MyMessage As String, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Character replaced with "?"
    ... > service is called by a windows client. ... The client send a crypted string ... And the numeric value of this character ... specifying the proper encoding in your web service call. ...
    (comp.lang.java.programmer)
  • Re: Processing and sending large data using Web Service
    ... How can I send such a big file using a web service to the client who ... This is writting to a string only for testing> purpose. ... How can I send such a big file using a web service to the client who> is consuming the web service? ...
    (microsoft.public.dotnet.framework.aspnet.webservices)