I have this class which is an input to my WCF service:
[DataContract]
public class LoginDTO
{
[DataMember]
public string Username { get; set; }
[DataMember]
public string Password { get; set; }
}
And here is the method in my service interface (IUserServices):
[OperationContract]
[FaultContract(typeof(ServiceException))]
[ServiceKnownType(typeof(LoginDTO))]
[WebInvoke(UriTemplate = "/login/", Method = "POST")]
UserDTO LogIn(LoginDTO loginInfo);
Testing my service (using Postman) causes this error:
System.Runtime.Serialization.SerializationException: Unable to deserialize XML body with root name 'LoginDTO' and root namespace '' (for operation 'LogIn' and contract ('IUserServices', 'http://tempuri.org/')) using DataContractSerializer. Ensure that the type corresponding to the XML is added to the known types collection of the service.
And I post this: (Content-Type => application/xml)
<LoginDTO>
<Username>MyUsername</Username>
<Password>MyPassword</Password>
</LoginDTO>
What am I missing, or what am I doing wrong?
No comments:
Post a Comment