Webservice help with parameters

C

Cralis

Hi guys,

I am trying to create my web service (Std ASP.Net), and what I do is
passes a custom object I have, which has string fields. One is
'CommandName'. On the web service, I get the object, check the
CommandName, and then do something, returing a string value.

Now, I need to pass a CommandName, and a variable number of parameters
(Depending on the command). So, I was hoping to pass a Dictionary of
String,String key value pairs. No go... It all fell apart. Now, I
assume it's due to web services not liking certain types. I had the
same iss with a List<>.

Could someone advise on the best way to do this?
 
C

Cralis

Actually, a List<String> would work, but .. I'd then have to set a
string to something like 'ParameterValue1,1'
 
J

Jeff Johnson

I am trying to create my web service (Std ASP.Net), and what I do is
passes a custom object I have, which has string fields. One is
'CommandName'. On the web service, I get the object, check the
CommandName, and then do something, returing a string value.

Now, I need to pass a CommandName, and a variable number of parameters
(Depending on the command). So, I was hoping to pass a Dictionary of
String,String key value pairs. No go... It all fell apart. Now, I
assume it's due to web services not liking certain types. I had the
same iss with a List<>.

Could someone advise on the best way to do this?

Maybe I'm missing something, but why not just an array of strings? You have
one property which is "string CommandName" and another which is "string[]
Parameters". Why would you need the extra string in a dictionary? For the
parameter name? You could always just require that the parameters be passed
in a specific order so you don't need to worry about a name. If you must
have that second string, make another class with two string properties and
pass an array of that class.
 
A

Arne Vajhøj

Actually, a List<String> would work,

Be sure to check that it become an array at the SOAP level.
but .. I'd then have to set a
string to something like 'ParameterValue1,1'

List<X> where X has two properties Name and Value seems
more nice.

Arne
 
C

Cralis

List<X> where X has two properties Name and Value seems
more nice.

Arne

This is what I tried...

I created an object called KeyValue, which had two properties, string
Key, and string Value.

However, as soon as I added that object to the list, and sent it, I
got an error. I can't recall the error... I'll try it again.
 
A

Arne Vajhøj

This is what I tried...

I created an object called KeyValue, which had two properties, string
Key, and string Value.

However, as soon as I added that object to the list, and sent it, I
got an error. I can't recall the error... I'll try it again.

Do that. And come back with the specific error if it still
does not work.

Arne
 
C

Cralis

Sorry for delay.

Arne - I added a List<String> and it seems to work perfectly now, so
all sorted!

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top