views:

190

answers:

2

I have a strange problem when I'm trying to call a simple webservice method from Jquery.

Locally it works fine, but on my test-server it does not.

The jquery request looks like this (only showing the actual request and not the rest of the method):

    $.ajax({
    type: "POST",
    url: "/Service/Service.asmx/AddTab",
    data: "tab=" + element.innerHTML,
    success: function(msg) {
        alert('success');
    }
});

When I run this locally from the test-server it works fine, which has me wondering if it could be some setting that I've missed in the IIS.

If I navigate to the .asmx file and click the AddTab method I get a list of SOAP 1.1 and SOAP 1.2 XML, but not the HTTP POST request. If I navigate to it locally I get all three (SOAP 1.1, SOAP 1.2 and HTTP Post)

The service is set up as follows:

 [WebService(Namespace = "mynamespace")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService()]
public class Service : System.Web.Services.WebService
{

    [WebMethod(EnableSession=true)]
    [ScriptMethod()]
    public void AddTab(string tab)
    {
        //Some code to add a tab which evidently works locally...
    }

   }

Anyone have a clue what I'm missing here?

+1  A: 

Make sure web.config file is properly configured.

kgiannakakis
The web.config looks exactly as specified in that post :/
Robban
+2  A: 

Managed to finally solve this by adding the following to the web-config:

<webServices>
  <protocols>
    <add name="HttpPost"/>
  </protocols>
</webServices>

Appearently the server was blocking the incoming requests from a remote host.

Robban