• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Web Services and NULL Parameters

I have the following ASP.Net Web Service:

<WebMethod()> _
    Public Function Insert_EJ_Data _
        (ByVal iEventID As Integer _
        , ByVal sLogFileName As String _
        , ByVal dtLogFileModDate As Date _
        , ByVal iRecordPosition As Integer _
        , ByVal dtRecord1 As Object _
        , ByVal iRecord2 As Integer _
        , ByVal iRecord3 As Integer _
        , ByVal sRecord4 As String _
        , ByVal dtRecord5 As Date _
        , ByVal iRecord6 As Integer _
        , ByVal iRecord7 As Integer _
        , ByVal iRecord8 As Integer _
        , ByVal iRecord9 As Integer _
        , ByVal sRecord10 As String _
        , ByVal sRecord11 As String _
        , ByVal sRecord12 As String _
        , ByVal sRecord13 As String _
        , ByVal sRecord14 As String _
        , ByVal sRecord15 As String _
        , ByVal sRecord16 As String _
        , ByVal sRecord17 As String _
        , ByVal sEventName As String) As Integer

        ' Other stuff is here
End Function

If when I call the web service I do not provide values for every single parameter, I get an error back indicating a cast error or the "argument not specified for parameter..."

Why won't it take NULL values?

Also, ideally I'd like to make it so that from the consuming application I can do:

Dim x As New localhost.EJ_Data

x.iEventID = Blah Blah Blah
x.sLogFileName = Blah Blah Blah

How would I go about this?

  • 4
  • 4
1 Solution
I'm a little confused, if it is your Web Service, why don't you just change it, so you insert only the parameters you want??

If you have to supply a parameter, just supply the word nothing has your parameter, and for the parameters you want supply the correct value.
ABaruhAuthor Commented:
I will try your second recommendation, inserting Nothing for the parameter that has no data.
ABaruhAuthor Commented:
Ok, passing the word Nothing works great, thank you.

What about the second part of my question, essentially creating these fields and passing those into some type of object like an array and then calling the Insert_EJ_Data and passing that array.  Any suggestions here?
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Ok, you need to create the DJ_Data object.  You know how to do this right?  You need a class.
During the constructor you have to set all of the DJ_Data "sub" objects equal to nothing.

Then in the class you built you need to add this for every "sub" object.

 myEventID as Integer

 Public Property iEventID() As Integer
             return myEventID
        End Get
        Set(ByVal Value As Integer)
             myEventID = Value
        End Set
    End Property

If you are used to object oriented programming then this will be pretty easy to accomplish.  If you don't know what I'm talking about or are not very good at OO programming, then you will have a lot of troubles trying to implement this.  You might be better off not doing it.
ABaruhAuthor Commented:
What about using delegates.  I'm not totally familiar with them, but the small amount of research I've done leads me to think that they can be a container of the values for my Insert_EJ_Data function.

Can you comment on this?
I can't comment too much about delegates, I've never used them before, and I am unaware of their behavior.
Typically in instances when you want to create your own object,  you'll want to create a class, but if you just want an object with no other methods/functions associated with it, it's possible that that's what a delegate does.  Sorry I can't provide any more help than that on delegates.
You might be able to create an array of objects... then cast the objects when you retrieve the data.  This MIGHT work.  Then you could just pass the array to the function.
ABaruhAuthor Commented:
Thanks, I'll award you the points and research more on my end.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now