1

我在 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
4

0 回答 0