2015-04-23 39 views
0

我在WCFrestful服務中使用post方法並使用它從ios,但在WCF方法中沒有獲取參數值。無法訪問ios中的wcf restful post方法

[OperationContract] 
     [FaultContract(typeof(ServiceData))] 
     [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/PassTwoParamsToCheckFault?firstparam={firstparam}")] 
     String PassTwoParamsToCheckFault(string firstparam); 

回答

0

要訪問POST請求的查詢字符串

[OperationContract] 
[FaultContract(typeof(ServiceData))] 
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/PassTwoParamsToCheckFault?firstparam={firstparam}")] 
String PassTwoParamsToCheckFault(string firstparam){ 
    if (context != null) 
    { 
     var result = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["firstparam"]; 
    } 
} 
+0

感謝您reply.Where寫這篇文章WCF服務?其實我是新來的wcf服務。 –

+0

根據您的要求修改答案。 – Rad

+0

感謝您的回覆,而不是在WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters [「firstparam」]上獲取「NullReferenceException」;線和什麼是背景 –