Identifying input parameter names of a function at run-time
Posted on 2008-10-04
I have a very strange question today:
I'm writing a VB.Net 2005 application that extracts data from SQL Server and passes it on to a web service. My problem is that the web service is not yet written. I know each field that I extract will have a corresponding input parameter in the web service function I will call. I don't know what the names or order of these variables will be though.
I was hoping I could at run-time determine what the name of each input parameter is, compare that to a map / settings file that could be manipulated by a user and as a result determine which source field in SQL Server to use.
To complete my development, I will write my own dummy web service. If I'm able to use the map I'm talking about, all we have to do once the real web service is completed, is to change the web service variable names in the map!
For example, if I have an XML file as the map, I could specify that Var1 is populated by the FIrstName field in SQL Server, any input variable called Surname is populated by the LastName field in SQL Server etc etc.
So, if my web service looks like this:
Private Function TheWebServiceMethod(Var 1 String, Surname String, SomeVar Integer) AS Boolean
When I call the web service and pass through variables, I could say that the value I'm passing through depends on what the input parameter is called. If it's called "Var1" I will pass though the FirstName value but if it's called "Surname" I will pass thought the LastName value and if it's called "SomeVar" I will pass thought the age.
I just don't know how to determine at run-time what the input parameter is called.....
Is it possible and if so, how do I do it?