Solved

Non mandatory parameters in a webservice??

Posted on 2004-08-25
3
707 Views
Last Modified: 2008-02-26
Hi

I'm about to make a webservice to handle logins from a windows pplication.
I need to make a method that takes userid/password and another method that takes userid/password/attribute1/attribute2.

I thought about just making one webmethod that took the 4 parameters as input. The problem is that the application uses http GET when contacting the webservice and when using GET the webmethod fails if some parameters are missing??

Is it possible to make some of the parameters "non mandatory"?

/Nicolaj
0
Comment
Question by:nicolajb
3 Comments
 
LVL 10

Expert Comment

by:123654789987
ID: 11890469
There is a particular XML tag called XMLIgnore.

You can try using it like this

[WebMethod]
public string Test(param1, XmlIgnore["param2"],param3)
{
}
0
 
LVL 19

Accepted Solution

by:
Desp earned 500 total points
ID: 11890482
C# lack this feature AFAIK.. even Vb.Net has this feature
http://oldlook.experts-exchange.com:8080/Programming/Programming_Languages/Dot_Net/Q_20829204.html

you can use overloading functions(polymorphism) ...but using some tricks you can acheive that as well:

using System.Reflection;
....
....
public bool GenerateRequest(string ,string ,string ,long ,string ,string ) // normal case

//you can use  System.Reflection.Missing.Value to pass optional parameters which are missed. so you call your GenerateRequest Method like this:

public bool GenerateRequest(string ,string ,string ,long ,  Missing.Value,  Missing.Value)

OR
Here is another way to do that:
http://builder.com.com/5110-6373-1050802.html
using the same technique used by Console.WriteLine method, where u dont know how many parameters you will pass to this.
0
 
LVL 9

Expert Comment

by:msdixon
ID: 11891680
one way i've handled this is to pass in an xml string (or XmlDocument if you prefer). this allows great flexibility, and parsing xml is pretty easy.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question