Reputation: 1
I am creating Rest services in WCF. I have a method GetUserDetails
which accepts three parameters GetUserDetails/?username={username}&mobileno={mobileno}&imeino={imeino}
.
But I am not able to parse this encoded url:
localhost:9005/Service.svc/GetUserDetails?request_header=null&request_body=%7B%22mobileNo%22%3A%229827098270%22%2C%22username%22%3A%22member%22%2C%22imeiNo%22%3A%22111111%22%7D
consist of Get Request with parameters in json format. Below is my code details:
[ServiceContract]
public interface IService
{
[OperationContract]
[FaultContract(typeof(string))]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, UriTemplate = "GetUserDetails/?username={username}&mobileno={mobileno}&imeino={imeino}")]
UserModel GetUserDetails(string username, string mobileno, string imeino);
}
public class Service : IService
{
public UserModel GetUserDetails(string username, string mobileno, string imeino)
{
try
{
con = new SqlConnection(strcon);
if (con.State == ConnectionState.Open)
{
con.Close();
}
SqlCommand cmd = new SqlCommand("SP_AND_userprofiledata",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@username", username);
cmd.Parameters.AddWithValue("@mobileNo", mobileno);
cmd.Parameters.AddWithValue("@imeiNo", imeino);
da = new SqlDataAdapter();
da.SelectCommand = cmd;
ds = new DataSet();
da.Fill(ds);
}
}
Any Help is greatly appreciated.
Upvotes: 0
Views: 805
Reputation: 156
Apparently, it does:
"For RESTful services, WCF provides a binding named System.ServiceModel.WebHttpBinding. This binding includes pieces that know how to read and write information using the HTTP and HTTPS transports, as well as encode messages suitable for use with HTTP."
from here.
Upvotes: 1