When i try to access web service from the development server, it returns the error below.
When I access the same service from my local machine, it works fine.
Do you have idea what might be the reason?
Thank you very much in advance!
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)
405 errors are often caused by cross domain issues. If you’ve deployed your service, but are testing from a client on localhost (or on another deployment), then everything is no longer running under the same localhost domain, so you need to enable cross domain calls.
A good example of enabling cross-domain scripting can be found here:
how to avoid cross domain policy in jquery ajax for consuming wcf service?
As @Monkieboy says, it’s a little hard to diagnose without seeing your web.config file, but try chaging whichever binding you are using by adding
crossDomainScriptAccessEnabled="true"and see if that helps.