Web Services and NULL Parameters

Posted on 2005-04-01
Medium Priority
Last Modified: 2010-04-07
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?

Question by:ABaruh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4

Accepted Solution

thrill_house earned 2000 total points
ID: 13683721
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.

Author Comment

ID: 13683961
I will try your second recommendation, inserting Nothing for the parameter that has no data.

Author Comment

ID: 13684065
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?
Industry Leaders: 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!


Expert Comment

ID: 13684113
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.

Author Comment

ID: 13684195
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?

Expert Comment

ID: 13684240
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.

Expert Comment

ID: 13684251
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.

Author Comment

ID: 13684332
Thanks, I'll award you the points and research more on my end.

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

800 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