This is a duplicate of http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/94503037-9cc4-494d-88af-4e97fcb9cdcc , but I did not have much success getting fruitful answers there. :(
I am trying to find information about getting a specific REST service client (proxy) from ChannelFactory.
As I understand it, you can install attirubtes on a client interface that tells WCF to use XML (DataContract or XmlSerialization) or JSON for responses, and HTTP requests with HTTP URLs or HTTP XML / JSON messages. [edit from original] And, of course, providing various binding configurations either programmatically or via config. [/ edit from original]
I would like to add some attributes to the service interface telling WCF to create a POST with a formatted URL, without an XML header, and then get a response in XML. (For example) [edit from original] And / or providing BCL bindings that support follosing [/ edit from original]
The sleepy scenario will be as follows:
public interface IRestClient { [WebInvoke] AuthResponse Authorize( [HeaderParameter] string someHeader, string someData, int someInt) }
And you have a client. Authorize actually
HTTP POST /authorize someHeader: abc someData=def&someInt=123
And deserialize
<AuthResponse> <Message>Hi there!</Message> </AuthResponse>
As far as I learned from googling searches and the forum, there is no way to do this unless you are doing a huge amount of plumbing, writing interceptors, formers and gods who know what.
WCF contribution library, WCF samples, etc. et al. is too academic and has too much plumbing and / or too little intuitive documentation for me to do this without pain. :)
Any clues where I can find the easiest way to do this?
(And please do not tell me to use HttpRequest or WebClient , so we have ChannelFactory ))
[update]
Correct me if I am wrong, but as I understand it, many so-called REST APIs require URL formatted requests, not Json or Xml.
The interpretation of WCF web interfaces in service descriptions reflects the WebGet and WebInvoke in method definitions to determine how each "method" is called in "services". (Let me call it a method and service for simplicity)
The WebInvoke attribute takes the value of the WebRequestFormat enumeration to determine how to serialize requests. In this listing, only Json and Xml.
It seems really stupid to me that this is an enumeration, and not some kind of pointer to a factory formatter / serializer, or even a specific one of these.
So, the question really comes down to the simplest, preferably already implemented, redefinition of query serialization.
[/ update]