0

カスタム オブジェクトを返す WCF サービスがあります (これはブラウザーで動作します) が、Javascript からサービスを呼び出すと、FF で無効なラベル エラーが発生します。をhttp://localhost/Service1.svc/MethodName/param1/param2ブラウザーに入れると、正しい情報が返されますが、JSONP に変換する前の JSON 応答と同じように見えます。応答を回避するラッパーがあるかどうかはわかりません。私が使用しているJavaScriptは以下のとおりです。

function CallService() {
$.ajax({
    cache:true,
    type: varType, //GET or POST or PUT or DELETE verb
    url: varUrl, // Location of the service
    data: varData, //Data sent to server
    crossDomain: true,
    contentType: varContentType, // content type sent to server
    dataType: varDataType, //Expected data format from server
    processdata: varProcessData, //True or False
    success: function (msg) {//On Successful service call
        ServiceSucceeded(msg);
    },
    error: ServiceFailed// When Service call fails
});

function SetupTrainList(tiploc) {
    try {
        varType = "GET";
        varUrl = "http://localhost/Service1.svc/MethodName/param1/param2";
        varContentType = "application/javascript";
        varDataType = "jsonp";
        varProcessData = false;
        CallService();
    }
    catch (e) {
        console.log(e.toString());
    }
}

WCF:

<OperationContract()>
    <WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare,
        Method:="GET",
        RequestFormat:=WebMessageFormat.Json,
        ResponseFormat:=WebMessageFormat.Json,
        UriTemplate:="MethodName/{param1}/{param2}")>
    Function MethodName(ByVal param1 As String, ByVal param2 As String) As ComplexType
4

0 に答える 0