tags:

views:

680

answers:

2

Trying to get this to work, with no luck:

[DataMember]
public Type ParameterType { get; set;}
+8  A: 

Web Services, in general, are meant to be cross-platform. What would a Java program do with a System.Type from .NET?

Also, what part of Type would you like to see serialized, and how would you like to see it deserialized?

John Saunders
I see the point. I really just need the type name which I can easily pass as a string.
AKoran
+1 exactly - anything definable in a XSD schema can be used, but no .NET specifics
marc_s
Any reason for a downvote, or did you just feel like it?
John Saunders
This deflects the question rather than attempting to answer it.
Marcus Griep
No, it's the direct answer. You can't return Type because of the nature of web services. Note the questioner apparently felt it not only attempted to answer it, but that it _did_ answer.
John Saunders
This is incorrect. The nature of web services allows one to transform serializable objects into the appropriate format: http://msdn.microsoft.com/en-us/library/cc656732.aspx; Just because it is `Type` doesn't make it special. The problem is that the runtime object is actually an internal type, which can't be wired: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/521852e0-d437-4def-848a-ead182a06276. Java could do whatever it wanted with the XML representation of something coming from .NET.
Marcus Griep
We're arguing the difference between the nature of web services and their implementation. Yes, an implementation could serialize System.Type (and its schema, remember), and let Java just choke on it. The current implementation of Type will not in fact permit serialization. How fast would that have changed if this were a popular use case?
John Saunders
A: 

Any field or property that returns System.Type is not serializable using WCF because, at runtime, the actual type of the object is System.RuntimeType, which is marked as internal, and thus cannot be automatically serialized by the DataContractSerializer, which can only serialize publicly accessible types.

However, you could write an IXmlSerializer wrapper around System.Type that will pull out the information you intend to transfer.

Marcus Griep