Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Wanna-Be C# Superstar
  • Administrators
Posted (edited)

Try the following...

    _
   Public Function Test(ByVal i As Integer)
       Test(i, 0)
   End Function

    _
   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

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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.

Wanna-Be C# Superstar

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...