2014-02-17 109 views
1

我有一个接受一个参数的Web服务。从fiddler调用Web服务方法

web服务方法:

[ActionName( “GetCustomers的”)]

[HttpPost] 

[AcceptVerbs("GET","HEAD")] 

public bool getcustomers(string id) 
{ 
    var result = JsonConvert.DeserializeObject<RootObject>(id.ToString()); 

    using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\Result.txt")) 
    { 
     file.WriteLine(result); 
    } 

    return false; 
} 

如果我运行下面提琴手..GetCustomer方法调用URL ....

url : http://localhost:49809/Import/GetCustomers/test 

如果我像屏幕截图一样使用json格式;

screen shot

我的webmethod是不是叫....让我知道为什么,如果它不叫..是通过JSON格式是给错误:HTTP/1.1 404未找到

回答

0

您需要将ContentType更改为Content-Type并删除其值附近的引号。

该行应为:Content-Type: application/json;charset=UTF-8