tags:

views:

362

answers:

3

I'm new to WCF

I have to create a WCF service that receives plain XML (not SOAP), does some processing then sends a reply message back in plain XML. I don't have a problem sending XML, I just need some tips on where to start. I'm familiar with creating web services in .Net with SOAP... with web services I would define the function to be called based on the SOAP request.

If I send plain XML to a WCF service (without defining a particular function like I do with SOAP)... what function does it hit? I need to set this up so all XML requests sent to my WCF hit a particular function... but how? Are they any good examples out there to do simply that? (I googled for links to receive plain XML in WCF, but didn't find anything for a beginner to WCF)

A: 

you can create an operation contract that receives and returns string. once you get the string - use regular dot net xml function to parse it and do whatever needed.

Good Starting point is reading Juval Lowey's book on WCF.

To answer the 2nd half - you don't "send" XML to the Service - you need to create a contract (function) whether it's a general one (single "function" - method) or many "functions" (methods).

Dani
Horrible solution. Yes, easy to implement, but very inefficient.
tomasr
Dot net is inefficient, but takes 30% less time to code than c++, so everybody use it. If you want to get results fast - you start with something simple, then improve it.
Dani
You can still keep it simple and not do that in WCF. No reason to hack it that way.
tomasr
I have Juval Loweys book, unfortunately they do not go into detail about Message Contracts because "it is by no means the usual case for common WCF applications"
Chris Klepeis
the book is a good basic reading, WCF has a lot more into it, and the book is old (yet a must read). I still find new things about WCF after using it for more than 3 years, haven't use message contract, so no help here....
Dani
+4  A: 

There are really two separate parts to this question.

  1. What protocol do you wish to expose your service on? HTTP? If so, you should take a look at WebHttpBinding, which was build for REST (or at least, POX) services. For more complex scenarios, you might need to go with a custom binding that doesn't force SOAP on the message.

  2. How you want to represent that XML on your service side. For example, with WebHttpBinding, the simplest scenarios is to still use DataContracts and let WCF take care of serializing to/from the XML text representation. However, it might be that you want to provide the raw XML somehow, and in that case, you could certainly go with a more raw contract using only System.ServiceModel.Channels.Message objects and handle the serialization process yourself.

tomasr
We will expose the service on HTTPS. I think what I want to use is WebHttpBinding with a Message Contract
Chris Klepeis
+1  A: 

You may want to check out examples that use WebHttpBinding (or other bindings with non-SOAP/WS-Messaging message types) and e.g. WebGet attribute with WebMessageFormal.Xml as the Request/Response types.

Brian
They're going to be posting so I don't think Webget will work
Chris Klepeis
In that case WebInvokeAttribute may be what you'd want.http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webinvokeattribute.aspx
Brian