views:

130

answers:

1

Hi all,

I've exposed a method on a web service to return an interface and sending back conrete classes using the [ServiceKnownType] attribute which works very well.

However, the wsdl description does not display any of its properties or any xml structure for this interface, this is the same when i send back List it gives it a default type of 'ArrayOfAny'. What I would like to do is replace this 'ArrayOfAny' XML structure in the WSDL with the structure of the known servicetype.

I know there is an interface 'IWsdlExportExtension' that can be implemented to get access to the wsdl creation and having done this i haven't a clue what to do next?

What process would i have to perform to make the WSDL 'output message' xml node have the xml structure of the conrete class that I'm actually sending back?

So basically, I just want to modify the wsdl input_message xml node with some custom content?

Any ideas?

+2  A: 

You cannot do this. The Service oriented world and with it WCF is built on XML schema, and you can only send concrete types across the wire. Remember - all that goes between the client and the server is a serialized message - there's no passing of references or anything - and only concrete classes can be serialized into a message.

What you can do (to a certain degree) is define a base class and then use the [KnownType] attribute to declare that other descendants might also be received and/or returned by a given operation.

Your only hope would be the NetDataContractSerializer, which you could use, if you control both ends of the communication channel (i.e. .NET-to-.NET WCF).

Check out these articles about that:

The NetDataContractSerializer packs .NET type information into your serialized message, thus enabling some whacky scenarios that a regular, interoperable service implementation can't handle.

UPDATE: - ok, I probably didn't quite get the gist of your question - does this article here A Sample IWsdlExportExtension for WCF help you maybe?

marc_s
I don't want to define the interface but a concrete class but still keep the interface as the method return type for flexibility. So if i can dynamicall inject the structure of the knowntype class the method will still be dynamic enough
Jon
I think you've miss understood a little bit, I have no problem with the interface part, i just want to modify the wsdl input_message xml node with some custom content?
Jon
I know there's a few things you can do with a custom WSDL exporter, but I've never seen anything like what you're looking for...
marc_s
Thanks i'll have a play, i'm just unsure whether i need to modify the schemas or something else to get this to work?
Jon