Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2004

Tip: Looking for answers? Try searching our database.

Passing a Null to Web Method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J. L. Goddard - 01 Aug 2004 04:49 GMT
1) Do c# web methods support default parameters ?

2) Can a web method, or a c# method such as:

    public nullTest( int i )
        {
            return i++;
        }

Can the web service consumer pass in a value of nullTest(null) ?

3) What if the web service is passing in a series of records where some
of the data for that parameter is null ?   How should a null be passed
to the web service ?

Signature

incognito @ http://kentpsychedelic.blogspot.com

Razzie - 01 Aug 2004 13:05 GMT
1) No. See http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx for
more info.
2) No. Maybe in Framework 2.0 where nullable variables or how you call it,
are supported. If the parameter type is an object, you can of course, pass a
null value.
3) Not sure I understand what you mean :)

> 1) Do c# web methods support default parameters ?
>
[quoted text clipped - 10 lines]
> of the data for that parameter is null ?   How should a null be passed
> to the web service ?
novelle.vague - 01 Aug 2004 17:48 GMT
Thanks.  That's a good blog.

Unfortunately for us web methods don't support overloading !

So for a consumer of a web service, he has to account for all parameters
with 'dummy data' I guess...

That means if his value is null, for an int, and he wants to pass a record
to me with a web service/method, he has to make up a value like 0, and use
that.

That's not good integrity.

> 1) No. See http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx
> for more info.
[quoted text clipped - 20 lines]
>> --
>> incognito @ http://kentpsychedelic.blogspot.com

Signature

http://kentpsychedelic.blogspot.com

William Stacey [MVP] - 01 Aug 2004 23:48 GMT
Not sure I understand the question fully.  But you could box the int in an
object and pass that or null ( I think ) or create a DBInt struct value type
like in Anders H. C# book (I just saw the code a bit.)

Signature

William Stacey, MVP

> 1) Do c# web methods support default parameters ?
>
[quoted text clipped - 10 lines]
> of the data for that parameter is null ?   How should a null be passed
> to the web service ?
novelle.vague - 02 Aug 2004 03:52 GMT
> Not sure I understand the question fully.  But you could box the int in an
> object and pass that or null ( I think ) or create a DBInt struct value
> type like in Anders H. C# book (I just saw the code a bit.)

So are you saying given:

public int NullTest(int i)
{
       returns i++;
}

I could say:

object o = null;        // box null into an object box
int value2 = (int) o;   // unbox into value2
public int NullTest(value2); // ???

Or should I configure NullTest() like:

public int NullTest(obj o)
{
       returns ((int) o) ++ ;
}

And call it with

object o = null;
int j = NullTest(o); // ???

Because a datatype o can be null, but a datatype int cannot accept a null
value when passed in as a parameter ?

Signature

http://kentpsychedelic.blogspot.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.