• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 646
  • Last Modified:

405 Method Not Allowed

I have the javascript function below which is attempting to make a jquery call to a simple .net function.

I am getting:
405 Method Not Allowed

This is my simple .net web service:
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class ReportInput
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String

Can anyone see what I am doing wrong?
function simsFunction() {
	    var settings = {requestType:"soap1.2",
	       error:function(XMLHttpRequest, textStatus, errorThrown){
	       throw XMLHttpRequest.responseText;
	     }};
     
		 var oBuffer = new Array();
		 settings.requestType = "soap1.2";
		 settings.methodType = "POST";
		 settings.contentType = "application/soap+xml; charset=utf-8";
		 //settings.url = "http://wsp-sandbox6.co.uk/ReportInput.asmx";
		 settings.url = "http://localhost:2256/CCBCWSTest/ReportInput.asmx/";
		 settings.dataType = "text/xml";
		  
		 settings.nameSpace = "http://tempuri.org/";
		 settings.methodName = "HelloWorld";
		
		 oBuffer.push('<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/soap/envelope/">');
		 oBuffer.push("<soap12:Body>");
		  oBuffer.push('<HelloWorld xmlns="http://tempuri.org/" />');      
		   oBuffer.push("</soap12:Body>");
		 oBuffer.push("</soap12:Envelope>");
		 settings.requestData = oBuffer.join("");
		 alert("requestData:" + settings.requestData);
  		   
		 $.ajax({
		   type: settings.methodType,
		   cache: false,
		   url: settings.url,
		   data: settings.requestData,
		   contentType: settings.contentType,
		   dataType: settings.dataType,
		   error: function(data,status){    	   	
		   	alert('data = ' + data.d);   	   	
		   },
			   success: function(data, testStatus){
			     alert('data = ' + data);	  
			   },
			   beforeSend: function(XMLHttpRequest){
			     if (settings.requestType == "soap1.1" || settings.requestType== "soap1.2")
			       XMLHttpRequest.setRequestHeader("SOAPAction",settings.nameSpace + settings.methodName);
			     XMLHttpRequest.setRequestHeader("Content-Length",settings.requestData.length);
			     XMLHttpRequest.setRequestHeader("Connection", "close");
			   }
		 });    
    }

Open in new window

0
scm0sml
Asked:
scm0sml
  • 2
  • 2
1 Solution
 
gery128Commented:
Try using Get method instead of Post

settings.methodType = "GET";  

instead of

settings.methodType = "POST";

Generally 405 means such kind of request is not allowed. Which may be configured thru IIS.
0
 
scm0smlAuthor Commented:
Same error I'm afraid?!
0
 
gery128Commented:
May I know why you are using complexe oBuffer object?

you can simply pass parameters directly to $.ajax function.

Refere this URLs

http://weblogs.asp.net/jalpeshpvadgama/archive/2010/08/29/calling-an-asp-net-web-service-from-jquery.aspx


http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
0
 
santhimurthydCommented:
Are you developing the application in VS2005 else higher version.
0
 
scm0smlAuthor Commented:
2010
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now