2014-04-09 2 views
-1

서비스 메서드에 액세스하는 동안 다음 예외가 발생했습니다. 내 서비스에서 제대로 작동하지만 GET 메서드를 실행할 때 POST 메서드를 실행할 때 500 개의 내부 서버 오류가 발생합니다. {: "30155496", "locationId": "10", "주문": "가 lorem" "userId를"}WCF 휴식 서비스 500 내부 서버 오류

서비스 코드

[OperationContract] 
[WebInvoke(Method = "POST", UriTemplate = "addorder", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] 
[FaultContract(typeof(ServiceException), Name = "ServiceException")] 
Standard AddOrder(string personId, int locationId, string order); 

https://mservice.domain.com/ServicesRestful.svc/json/addorder

오류 메시지

들어오는 메시지의 형식이 'Raw'입니다. 작업의 예상 메시지 형식은 'Xml'입니다. 'Json'. 바인딩에 WebContentTypeMapper가 구성되지 않았기 때문에 이 될 수 있습니다. 자세한 내용은 자세한 내용은 WebContentTypeMapper 설명서를 참조하십시오.

+1

오류 메시지가 일반 영어이면 * 자세한 내용은 WebContentTypeMapper 설명서를 참조하십시오 .'? – nvoigt

답변

0
이 방식으로 계약을 변경

:

[OperationContract] 
[WebInvoke(Method = "POST", UriTemplate = "addorder", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)] 
[FaultContract(typeof(ServiceException), Name = "ServiceException")] 
Standard AddOrder(Order order); 

당신의 Order 클래스 인 경우 :

[DataMember] 
public class Order 
{ 
    [DataContract] 
    public string personId {get; set;} 
    [DataContract] 
    public int locationId {get; set;} 
    [DataContract] 
    public string order {get; set;} 
} 

지금 시도하고 실행. JSON이 올바른 형식인지 확인하십시오.