Submit an Object from a web service client

VBAHole22

Contributor
Joined
Oct 21, 2003
Messages
432
Location
VA
I have a web service method that I would like to have optional parameters so that I don't have to write 3 overloaded methods and name them all differently.

Wouldn't it be easier to just pass in an object from the client?
That way I wouldn't get errors when the client doesn't submit the double that my web service defines (because it is optional in the method).

I could receive the object and then work on it server-side in my service.

How do I go about doing this? I guess I am confused because of the web service client that .NET creates by default for my service. Can I just override that ugly default page and make my own client? My users will not want to use the page itself anyway. They are going to have their own client pages.

Am I missing something here?
 
Try the following...
Visual Basic:
    <WebMethod(MessageName:="Test1")> _
    Public Function Test(ByVal i As Integer)
        Test(i, 0)
    End Function

    <WebMethod(MessageName:="Test2")> _
    Public Function Test(ByVal i As Integer, ByVal j As Integer)

    End Function

although in the test page it will display both test1 and test2 create a sample app and reference the web service - you will just get 2 versions of the Test method.

If you are referring to the page you get when you run a web service then do not worry - that is just there as a convenience for the developer. In practice you would never expect a user to access it
 
Last edited:
Did not know that, thank you.

Why is it that you double parameters are required yet things like string you can leave blank? I can't even get into my code to handle the null because the service blows up first.
 
Back
Top