Reputation: 969
How messages are transferred in WCF rest services? Is there any rest envelope? Please suggest.
Upvotes: 0
Views: 227
Reputation: 7067
A REST Web Service does not have an envelope structure, but rather just utilizes Http (address, method, header, body).
The Http Header(s) can be accessed using:
WebOperationContext.Current.IncomingRequest.Headers
The Http message body can be accessed using:
OperationContext.Current.RequestContext.RequestMessage
In order to more thoroughly understand / visualize the REST Web Service message structure, you could host a simple WCF Rest Web Service, enable tracing and then send a few messages. The trace file will show the Http message (headers and body) as such:
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<Connection>close</Connection>
<Content-Length>10531</Content-Length>
<Content-Type>application/xml</Content-Type>
<Accept>*/*</Accept>
<Accept-Encoding>gzip;q=1.0,deflate;q=0.6,identity;q=0.3</Accept-Encoding>
<Host>127.0.0.1:18100</Host>
<User-Agent>Ruby</User-Agent>
</WebHeaders>
Note: if you need additional implementation information, the following link provides a fairly comprehensive and straightforward overview of WCF Rest Web Service implementation:
http://www.codeproject.com/Articles/571813/A-Beginners-Tutorial-on-Creating-WCF-REST-Services
Regards,
Upvotes: 2