In my WCF service I only want 1 endpoint (1 URI), however, I want this URI to be able to handle multiple types of requests. 5 different request types can be sent to this service from another company. Each request has a unique XML schemas.
I created classes for each XML request to be serialized. Normally I would just overload a function when the parameter is different.... however I cannot do this in this instance because the UriTemplate of my WCF functions are the same, and throws errors when I try to run the app (saying the UriTemplate must be unique).
In each XML request is a node named "requestType". I'm trying to get a feel for what others would do... should I serialize on my own and ignore the built in serialization from the DataContract? What type of parameter should I set my function to accept... an XMLDocument then based on the requestType branch out to the request specific logic?
The returned XML from this function is also unique based on the request type.... however I cannot return an XMLDocument from an OperationContract... more errors are thrown (I think because it said it cannot be serialized).
I've tried creating a class that can get serialized from all request types by setting
IsRequired = false, EmitDefaultValue = false
...on the DataMembers for objects that are not shared amongst the different request types. I'm now running into a problem where the Order has to be properly set for each DataMember otherwise it doesn't get serialized at all into my class object.... I would have thought the Order wouldn't have to be set :/
Edit:
This is what I'm using now... the XML is POSTed to my service.
[WebHelp(Comment = "comment")]
[WebInvoke(UriTemplate = "foobar",
Method = "POST",
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Xml)]
[OperationContract]
public ResponseType foobar(ReqeustType request)
...
When testing I would post XML to http://localhost:4011/XMLWCF/Service.svc/foobar