【发布时间】:2012-08-25 05:46:26
【问题描述】:
当我尝试从开发服务器访问 Web 服务时,它返回以下错误。 当我从本地机器访问相同的服务时,它工作正常。 你知道可能是什么原因吗? 非常感谢您!
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (405) Method Not Allowed. ---> System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Portal.ExportSvcReference.IExportDataService.AddDataRequest(ExportData request)
【问题讨论】:
-
方法签名改变了吗?
-
不,方法签名没有改变。
-
它在同一个地方为 Web 服务提供相同的代码。只是与代码网站相同的不同位置在调用它。
-
如何调用 WCF 服务?
-
如果服务已部署,但您的客户端脚本仍在本地主机上运行,您可能遇到了跨域问题。有关如何启用跨域访问的信息,请参见此处的答案:stackoverflow.com/questions/5686059/how-to-avoid-cross-domain-policy-in-jquery-ajax-for-sumption-wcf-service
标签: c# asp.net-mvc-3 wcf