Chris Klepeis
Chris Klepeis

Reputation: 9973

.Net WCF - Receiving & Sending XML

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)

Upvotes: 1

Views: 3415

Answers (3)

Brian
Brian

Reputation: 118855

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.

Upvotes: 1

tomasr
tomasr

Reputation: 13849

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.

Upvotes: 4

Dani
Dani

Reputation: 15069

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).

Upvotes: 0

Related Questions