寻找关于wcf 4休息服务的一些指导,该服务基于VS2010中的WCF REST模板40(CS)扩展.我花了最近几天试图让这个bug工作,审查其他帖子,而我已经接近,我似乎无法越过终点线.经过很多挫折之后,它终于点击了服务并发布了(使用fiddler请求构建器),但是方法参数是null,但它在请求构建器中正确设置.我猜这可能是配置问题,但随着截止日期的临近,我没有时间进行更多的研究.FWIW,在调试中,jsonstring变量为null.自我肯定是一个菜鸟问题,因为这是第一次通过REST为我,任何帮助将不胜感激!
提前致谢.
web.config中
<system.web>
'<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
的global.asax.cs
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("Scoring", new WebServiceHostFactory(), typeof(ScoringSvc)));
}
}
Run Code Online (Sandbox Code Playgroud)
服务代码
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class ScoringSvc
{
[OperationContract]
[WebInvoke
(Method = "POST",
BodyStyle …Run Code Online (Sandbox Code Playgroud)