簡體   English   中英

解碼編碼的URL

[英]Decoding encoded URLs

我正在WCF中創建Rest服務。 我有一個方法GetUserDetails ,它接受三個參數GetUserDetails/?username={username}&mobileno={mobileno}&imeino={imeino}

但是我無法解析此編碼的URL:

本地主機: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

由具有json格式參數的Get Request組成。 下面是我的代碼詳細信息:

[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);

    }
}

任何幫助是極大的贊賞。

顯然,它可以:

“對於RESTful服務,WCF提供了一個名為System.ServiceModel.WebHttpBinding的綁定。該綁定包括一些知識,這些知識知道如何使用HTTP和HTTPS傳輸來讀寫信息,以及編碼適合與HTTP一起使用的消息。”

這里

參見: http : //www.stackoverflow.com/questions/1187744/does-wcf-automatically-url-encode-decode-streams/1507218#1507218

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM