2012-08-17 3 views
0

내 WCF 서비스에서 통계를로드하려고하면 잘못된 요청 오류 400이 발생합니다. 내 전화는 그렇게 보입니다. 그 원인인지 확인하기 위해 date 매개 변수를 꺼 냈지만 여전히 같은 오류가 발생하지는 않습니다.잘못된 요청 - jQuery 게시 WCF

function WCFJSON() { 
//var now = new Date(); 
//var getFromDate = dateToWcf(new Date(now - (60000 * 1440))); 

var dt = new Date(now); 
var dt1 = new Date(Date.UTC(dt.getFullYear(), dt.getMonth(), dt.getDate(), dt.getHours(), dt.getMinutes(), dt.getSeconds(), dt.getMilliseconds())); 
var getFromDate = dt1.toMSJSON(); 

var userid = "1"; 
m_Type = "POST"; 
m_Url = "https://dev-04.boldgroup.int/ManitouDashboard/DashboardProxyService.svc/GetStats" 
m_Data = JSON.stringify({getFromDate: "'" + getFromDate + "'",getValueList: [1,2,3]}); 
m_DataType = "json"; 
m_ProcessData = true;    
CallService(); 
} 

Date.prototype.toMSJSON = function() { 
var date = '//Date(' + this.getTime() + ')//'; //CHANGED LINE 
return date; 
}; 

function CallService() { 
$.ajax({ 
    type: m_Type,   //GET or POST or PUT or DELETE verb     
    url: m_Url,     //Location of the service 
    data: m_Data, 
    dataType: m_DataType, //Expected data format fserver     
    processdata: m_ProcessData, //True or False 
    crossdomain: true,  
    contentType: "application/json; charset=utf-8",    
    success: function (msg) { //On Successfull service call      
     ServiceSucceeded(msg); 
    }, 
    error: function (jqXHR, textStatus, errorThrown) { 
     ServiceFailed("jqXHT: " + jqXHR.result + "Text Status: " + textStatus + " Error Thrown: " + errorThrown); 
    } // When Service call fails    
}); 
} 

는 IDashboardWCFService 인터페이스는 다음과 같습니다 : 당신이 $ 아약스 방법을 통해 도메인 간 웹 서비스 호출을 수행하기 위해 노력하고있다처럼

[ServiceContract] 
public interface IDashboardWCFService 
{ 
    [OperationContract] 
    [WebInvoke(UriTemplate = "GetStats", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] 
    Dictionary<int,List<StatValue>> GetStats(DateTime getFromDate, List<int> getValueList); 

    [OperationContract] 
    [WebGet(UriTemplate = "GetStatTypes", ResponseFormat = WebMessageFormat.Json)] 
    List<StatType> GetStatTypes(); 
} 
+0

서비스를 검색 할 수 있습니까? WebInvoke()에 대한 메소드가 없습니까? 그럴 수있어? –

답변

1

이 보인다. 이 경우 m_dataType 값은 "json"이 아닌 "jsonp"이어야합니다.

비슷한 질문은 here입니다.

관련 문제