Yes, it is possible and Tequila's answer is very close to what was expected:
[ServiceContract]
public interface IWeChatBOService
{
[WebGet(UriTemplate = "WeChatService/{msgBody}")]
[OperationContract]
string ProcessRequest(string msgBody);
[WebInvoke(Method = "POST", UriTemplate = "WeChatService")]
[OperationContract]
string ProcessRequest2(string msgBody);
}
But I would not recommend designing such an api. It is better to describe the base uri in the enpoint description, the UriTemplate should reflect the resource identifier:
[ServiceContract]
public interface IWeChatBOService
{
[WebGet(UriTemplate = "messages/{messageId}")]
[OperationContract]
string GetMessage(string messageId);
[WebInvoke(Method = "POST", UriTemplate = "messages")]
[OperationContract]
string InsertMessage(string message);
}
Here is a good tip:
Best REST Techniques
RESTful API Design
source
share