Hi Everybody,
I'm currently working on a dev project that comprises both a client part (ASP.NET 3.5) and a Server part (WCF & NHIBERNATE). The client app talks to the service using REST but I'm getting a lot of problem when Posting.
-I've got this Entity:
-I've got this method on the client application:Code:namespace Adecco.SGICC.Model { [DataContract(Name = "Platform", Namespace = "http://Adecco.SGICC.Model")] public class Platform : StatedEntityBase { [DataMember] public virtual string Description { get; set; } [DataMember] public virtual string Name { get; set; } [DataMember] public virtual string Code { get; set; } public Platform() { } public Platform(int id) { this.Id = id; } } }
public int SavePlatform(Platform platform)
that ends up doing something like this:
-After executing PostForObject, I get the following exception:Code:RestTemplate myRestTemplate = new RestTemplate(); myRestTemplate.PostForObject<T>(uri, content);
"Could not write request: no suitable HttpMessageConverter found for part type [Adecco.SGICC.Model.Platform]"
-In the SavePlatform(Platform platform) I use a DataContractHttpMessageConverter and add the Platforms' type to it as a SupportedMediaType like this:
And it still keeps throwing the same exception...Code:foreach (KeyValuePair<string, object> item in content) { Spring.Http.MediaType mediaType = new Spring.Http.MediaType(item.Value.GetType().Name); if (!myIHttpMessageConverter.SupportedMediaTypes.Contains(mediaType)) { myIHttpMessageConverter.SupportedMediaTypes.Add(mediaType); } }
Does anybody here know what the heck I'm doing wrong here?!?!
Thanks a lot!!!
fretwio


Reply With Quote
