Jon
Jon

Reputation: 4295

Make an interface structure appear in a WSDL

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?

Upvotes: 0

Views: 719

Answers (1)

marc_s
marc_s

Reputation: 754548

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?

Upvotes: 2

Related Questions