Returning a Generic from a web service

  • Thread starter Alexander Walker
  • Start date
A

Alexander Walker

Hello

I have a web method that returns a List<T>

I have noticed that the proxy class generated with wsdl.exe does not return a
type of List<T> but instead it returns a type of T[] is there some way I can get
wsdl.exe or the Visual Studio IDE to generate a proxy class that will return a
List<T>?

I understand that I can edit the class generated by wsdl.exe myself but I would
prefer not to do this as I would have to edit the file every time I regenerated
the proxy

Thanks

Alex
 
S

Steven Cheng[MSFT]

Hi Alex,

Welcome to the MSDN newsgroup.

As for the generating client proxy for ASP.NET webservice that contains
generic types parameters/return value problem you mentioned, this is an
expected behavior due to XML webservice's nature.

Basically, webservice only publish the WSDL document as the service
contract to client users. And client users (some webservice toolkit or
component) will generate the proxy code from the WSDL document. However,
because WSDL document is based standard XML schema, no matter what
platform specific types we haved used in webservice code, the WSDL document
will use standard xml schema types to represent them. And for .net
framework, such types like List, ArrayList, Collection will be represented
by xml array. Also, using such standard xml schema types can help
different client platform able to generate the correct proxy types to map
the webservcie parameters/return values.

Therefore, for your scenario, your webservice client is also using .net
framework and you want to have the client proxy also use the .net specific
types (the same as serverside service code), you have to manually modify
the generated proxy code.

Please feel free to let me know what you think.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top