How can I use WCF Services without DataContract and DataMember?
I am working on a web application and serialize objects using JSON.Net
. Now I want to add some WCF services to this application that will be used on any platform like Android.
now when i send a simple ajax request to the web service it goes to endless loop and chrome loops logs net::ERR_CONNECTION_RESET
but when i add DataContract
to the model these problems are solved but in a different form throughout the application JSON.Net
does not serialize objects.
Here are my codes:
[ServiceContract]
public interface IProductService
{
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "product/grid/special?start={start}&size={size}&orderBy={orderBy}&orderByType={orderByType}&productListId={productListId}")]
PagedResult<Product> specialGrid(int start, int size, string orderBy, string orderByType, int productListId);
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ProductService : IProductService
{
IProductRepository productRepository;
public PagedResult<Product> specialGrid(int start, int size, string orderBy, string orderByType, int productListId)
{
//return start + " " + size + " " + orderBy + " " + orderByType + " " + productListId;
productRepository = new ProductRepository();
SearchOption s = new SearchOption(start, size, orderBy, orderByType);
return productRepository.getSpecialSaleProducts(s, productListId);
}
}
[Table("Product")]
[DataContract]
public class Product : BaseEntity
{
public string title { get; set; }
}
0
source to share
No one has answered this question yet
See similar questions:
2
or similar: