0

The service I'm trying to call is deployed as part of a visual web part. If i call it directly: _layouts/service.asmx I get the expected service page, showing me the functions I want to call. When I do the Jquery Ajax call (it works just fine on my development server) I get a 500 error back from the server.

$.ajax({
    url: 'http://myserver/_layouts/service.asmx/GetLinksToAllFav',
    data: "{'tag': '" + $('#MyTag').val() + "', 'TagMaxLength': '" + $('#TagMaxLength').val() + "'}",
    type: 'POST',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
        $('#MyFav').html(data.d);
        $('#MyFav').show(100);
    },
    error: function (all, textStatus, errorThrown) { console.log(textStatus); console.log(errorThrown); }
});

Response HTTP/1.1 500 Internal Server Error

devzero
  • 2,510
  • 4
  • 35
  • 55
  • my friend if you get 500 Server Error, there is NO way to help you if you show us the CLIENT code... you need to debug your service.asmx... – Luke Jan 27 '12 at 15:21
  • what do you mean with "call it directly, it works"? How you call a POST request with data directly? – Luke Jan 27 '12 at 15:23
  • Call it directly: I input the url http://localhost/_lauouts/service.asmx in the browser, getting the service page, there I can choose the function I want (GetLinksToAllFav) I then get a form I can input data in and call the function, getting the expected result. It's the AJAX call that gets me a 500 error. – devzero Jan 27 '12 at 21:25
  • Moss logs just shows: "Entering monitored scope ", then "name= Request.." then "Leaving monitored scope .." – devzero Jan 27 '12 at 22:05

1 Answers1

0

To get this to work I had to add the following to the web.config file.

  <system.web>
    <webServices>
      <protocols>
        <add name="HttpGet" />
        <add name="HttpPost" />
      </protocols>
    </webServices>
devzero
  • 2,510
  • 4
  • 35
  • 55