tags:

views:

719

answers:

2

I'm attempting to call a DomainService created using WCF Ria Services from jquery. If I use a POST I get 405 method not allowed. If I use Get, it get javascript errors. Am I missing a configuration step? This code results in the 405.

 function GetSearchResults() {
  $.ajax(
 {
  type: "POST",
  url: "/Services/CustomerService.svc/GetCustomerSearchResults",
  data: '{"customerId":1}',
  timeout: 5000,
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: Success,
  error: Fail
 });
 }

[EnableClientAccess]
public class CustomerService : DomainService
{
 public List<CustomerSearchResult> GetCustomerSearchResults(string customerId)
 {


  var list = new List<CustomerSearchResult>();
  list.Add(new CustomerSearchResult
   {
     Id = 1,
                                   Name = "Me"
   });
  }

  return list;
 }

}

+1  A: 

It's a bit more complicated than that. This article explains how to connect jQuery with WCF.

Diadistis
I've read that article but my question is slightly different. I'm not accessing a typical WCF services, but instead a DomainService which a Ria Service.
JNappi
A: 

Ria Services uses HttpModule to handle any request to a domain Service, this is a request url i got from fiddler "http://localhost/Ccp/ClientBin/CommunicationService.svc/binary" , the function name itself added to the request header.

try use this pattern it may work with Javascipt.

Mina