I am struggling few hours with this and can\'t find a solution to the communication problem. My service need to communicate with clients via SOAP or plain XML
My service
The service you have here will return a SOAP message - which will contain the "CompositeType" as its "payload".
WCF by default uses SOAP - any of the basicHttpBinding, wsHttpBinding, netTcpBinding etc. all work with SOAP as their basis.
If you want to return straight XML, you need to check out the REST capabilities of WCF - this works with the webHttpBinding
(and only that binding).
Also, how to produce an XML like this (based on data contract):
<CompositeType BoolValue = 0 StringValue = "">
rather than this:
<CompositeType>
<BoolValue>0</BoolValue>
<StringValue></StringValue>
</CompositeType>
This is a limitation of the WCF DataContract serializer. For performance reasons, it does not support attributes, e.g. you cannot create the first fragment of XML that you want.
If you absolutely must have the first XML, you'll need to use the XmlSerializer instead (which has its own set of limitations / problems).
Marc
UPDATE: if you just want to return a given XML, then you're probably better off with the REST approach.
Check out the Pluralsight website for an excellent series of screencasts on using REST and in particular, one screencast on how to create a plain-old XML (POX) REST service.
Take a look at Enunciate. I've used it before to create a REST (XML && JSON) interface as well as a SOAP interface. It might give you exactly what you're looking for and it's pretty easy to work with. The lead developer is also quite active on the mailing list so if you have questions just send the group a message and you'll usually get a response very quickly.