views:

46

answers:

1

This isssue may have several aspects so please read through first.

Suppose that you have a stuct with a few small ints that pack well into Int64 and while you want to use your struct as a type in C# you want it to be exposed as In64 via web methods - so that WSDL has it and you retain basic REST ability (simple types make GET invocation possible).

The closest to that I've found so far is SqlDateTime - it auto-morphs into dateTime in WSDL (there's an attrib that seems to govern XSD/WSDL type equivalence plus IXmlSerializable) but that's not enough. The web method still gets recognized as "having complex params" and therefore is rendered unavailable to GET requests.

Update: XSD/WSDL and SOAP invocation respected type equivalency perfectly fine - the problem is with GET invocation - the RESTful URL path doesn't get generated at all.

Looking for info on possible additional attribs, interfaces, hook-up points, of if someone stumbled upon a struct or internal class that managed to do full type equivalence with any "primitive", scalar type (DayTime is not exactly primitive but still gets such treatment). Also if soemone knows a way to establish stronger type equivalence or add/mark a struct to be treated as a simple (scalar) value type - even better.

Please don't post just to say something nasty or preach private ideology. This is serious, gray-zone question for people who know their way in Reflector and read the code. If you think you can ideologize this you don't even have the clue about the issue. If however you can point to actual code that causes/makes the decison about what will be servable via GET request please post even if by doing that you prove the impossibility of extending type equivalence to GET requests.

Oh and CLR is 2.x/3.x.

Thanks to those who help and to those who don't disrupt.

A: 

This is not doable.

Why would it be? You're talking about an egregious hack. Why on Earth would .NET ever support it, or allow it?

The only thing you'll be able to do is to implement the IXmlSerializable interface on your struct, so you can do the serialization and deserialization yourself.

John Saunders
True, but wondering what is so egregious? Your snarki-ness doesn't add value.
jro
I find it egregious, when using a modern programming language, to expect it to be like C or C++, where you can just hack a high-level data structure into pretending to be a sequence of bytes. In fact, I doubt I'd even bother doing this. Does a few extra bytes of XML actually matter in your problem space? If so, then you probably shouldn't be using text-serialized XML at all, but should be using the DataContractSerializer, which can emit binary-serialized XML - a much more compact format.
John Saunders
It's not about a few bytes - it's about being able to serve GET and still retain such type as web methos param. Yes I also need IXmlSerializable and WSDL has no problem taking simple XSD type equivalent - nothing that SqlDataTime hasn't done before. Please read the stuff before jumping the gun to preach instead of trying to help - ideology has never helped anyone.
ZXX
@zb: experience has been very helpful to many, except for those who ignore it.
John Saunders
Experience is helpul when it's concrete and covers one's actual problem. Presumption that you are entitled to preaching with zero knowledge about actual context counts as a lack of it. Don't know if you ever served multiple wire formats from .NET WS engine with multiple paths of invocation and unified codebase - if you actually read the question than you know by know that SOAP part is almost trivial and not even the subject of the question.
ZXX
@ZXX: you did not state that you are attempting to adhere to a specific wire format dictated by external requirements. Everything you have said before this last comment suggested that you were doing this for your own reasons. The only valid reason I know of for doing something like this is "external requirement".
John Saunders
When someone asks particular question, and not a general design advise question it's quite inappropriate to assume that he somehow has to justify his question and even more inappropriate to essentiually kill his chance to receive any meninfull reply by breaking into ideological diatribe. It defeats the very purpose of the site like StackOverflow and will just make people go somewhere else. The claim to fame of StackOverflow was that you'll stumble on someone who can answer a hard question, now waste a day or two on pointless ideology spews.
ZXX
@ZXX: most people looking for help are pleased to supply adequate information. Sorry, but the number of people who ask apparently stupid questions who actually know what they're doing is very, very small. I'd estimate that less than 1% of people asking a similar question actually have a specific requirement. Read your first paragraph again. "Suppose you have". You would have received a totally different answer if you'd said, "Suppose you have a struct and need to adhere to some specific wire format".
John Saunders
I asked you do delete your comments so that I can delete my and give my question a fresh start - didn't ask for more insults. Don't know why do you consider yourself entitled to be the judge and jury and go around preaching and insulting based on your presonal prejudices but it's just straight disrespectful and detrimental for the site as a whole, especially in concrete questions which explicitly asked people not to post "I don't think it's doable". Respecting a bare minimum of what a person asked shouldn't be so hard.
ZXX