405不允许使用方法,Windows Azure WCF Rest服务

时间:2013-07-05 09:46:58

标签: asp.net-mvc-4 azure

我在Webrole中定义了一个json rest服务,并在另一个webrole中使用。但每当我调用该方法时,它会抛出405异常。

[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
        List<String> Registration();

当我拨打电话时

            new MmdRef.MMDServiceClient().Registration().ToString();

它抛出异常,但如果我向fiddler发出请求,它会很高兴地返回响应。

栈跟踪 :

[WebException: The remote server returned an error: (405) Method Not Allowed.]
   System.Net.HttpWebRequest.GetResponse() +8527180
   System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +237

[ProtocolException: The remote server returned an unexpected response: (405) Method Not Allowed.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +14541042
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +622
   MMDUI.MmdRef.IMMDService.Registration() +0
   MMDUI.MmdRef.MMDServiceClient.Registration() in c:\Users\Andrew\Documents\Visual Studio 2012\Projects\MMD\MMDUI\Service References\MmdRef\Reference.cs:101
   MMDUI.Controllers.RegisterController.Index() in c:\Users\Andrew\Documents\Visual Studio 2012\Projects\MMD\MMDUI\Controllers\RegisterController.cs:17
   lambda_method(Closure , ControllerBase , Object[] ) +113
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +261
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +34
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +124
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +838059
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +33
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +838644
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

0 个答案:

没有答案