Sending an Enum as a parameter to a web service.

C

Charlieee

Has anyone tried sending an Enum as a parameter to a web service?

We can only get it to work if we take the Enum and cast it to an int then
parse it back within the web method.

The docs show that Enum is [Serializable] so we are thinking that it should
just serialize itself to the web method via .NET.

This should work???
WebServiceProxy.GetSomething(myEnum.ExtendedStuff, otherParameters);
(myEnum is defined in both the Client and Web Service.)

Once we cast with int, everything works well, for example:
WebServiceProxy.GetSomething((int)myEnum.GetExtendedStuff, otherParameters);

We've also tried:
WebServiceProxy.GetSomething(WebServiceProxy.myEnum.GetExtendedStuff, .....)
But the system hangs.

Is it necessary to cast or is there something we are missing?


Charlie
:)
 
A

alantolan

Where is the enum declared/defined?

Is it in a dll that is shared by both the client and the web
service?, or
Is it declared twice, once in the service, and once in the client?

If once in each, try turning on option strict. It should give you an
error as they will be different types.

Any types that need to be used by both the client and webservice need
to be defined in a common dll.

hth,
Alan.
 

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

Top