Reputation: 3
I am trying to create a logging service using WCF Rest. It looks something like this:
[ServiceContract]
public interface ILoggingService
{
[OperationContract, WebGet(UriTemplate = "/LogError?m={message}")]
void Log(string message);
}
I have increased the limits in the configuration file so you can log a fair amount of text. However if I go over this limit the service does not accept the message. So far I have made sure that the text is below the limit but this is a poor work around. How do I get around this problem in WCF REST.
UPDATE
After further investigation, I should end up with something that looks like this?
[ServiceContract]
public interface ILoggingService
{
[OperationContract, WebGet(UriTemplate = "/LogError?m={message}", Method = "POST")]
void Log(string message);
}
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);
request.Method = "POST";
request.ContentType = "text/plain";
Upvotes: 0
Views: 1900
Reputation: 14483
For a http post I think the signature would look like
[OperationContract]
[WebInvoke(UriTemplate = "LogError",Method="POST")]
void Log(string message);
Using posts sends the data in the http request and not in the url.
Http get request should only be used to read data, post for creation, put for updating and delete for deletion.
http://en.wikipedia.org/wiki/Representational_State_Transfer
Upvotes: 1
Reputation: 142202
I would recommend not using a GET method. The operation you are performing is a write, not a read. If you use POST, you can send an entity body using the media type text/plain. That way you are not limited by the url length.
Upvotes: 1