【问题标题】:Calling a web service method from ASP.NET 1.1 using jQuery ajax, not returning any data.使用 jQuery ajax 从 ASP.NET 1.1 调用 Web 服务方法,不返回任何数据。
【发布时间】:2012-09-11 14:57:28
【问题描述】:

我托管了一个 Web 服务,该服务由 jQuery ajax 从 ASP.NET 1.1 调用。

这是我用来调用网络服务的代码:

function OnTrimLevelChange() 
{
    var $jDecode = jQuery.noConflict();
    var vin = $jDecode("input[id*=txtVIN]").val();
    var styleId = '';
    var paramList = '{"vin": "' + vin + '","styleID": "' + styleId + '"}';
    try
    {

        $jDecode.ajax({
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            url: 'http://192.168.10.10/VINDecoder/service.asmx/CallADSWebMethod',
            data: paramList,
            dataType: 'json',
            success: function(data) {
                alert('I am here');
        },
            error: function(xml,textStatus,errorThrown) {
                alert(xml.status + "||" + xml.responseText);
            }
        });
    }
    catch(er)
    {
    }
}

================================================ ========
上面的总是去错误部分。
错误:
xml.status = 0
xml.responseText = null

网页方法代码是:

[WebMethod]
public VINDescription CallADSWebMethod(string vin, string styleID)
{
       VehicleDescription vehicleDescription = FetchVehicleInfo(vin, true, styleID);

        VINDescription vinDescription = new VINDescription();

        try
        {
            if (vehicleDescription != null)
            {
                //Check if the response status of the call is successful or not.
                if (vehicleDescription.responseStatus.description.Equals("Successful"))
                {
                    vinDescription = AddToVINDescription(vehicleDescription);

                }
            }
        }
        catch (NullReferenceException ex)
        {
        }
        return vinDescription;
}

注意:网络服务是在 .Net 4.0 中创建的,而我从中调用的站点是在 1.1 中。 它们托管在不同的服务器中。

请让我知道我在这里缺少什么或者我做错了什么......

【问题讨论】:

  • 返回的错误是什么? xml.responseText
  • xml.status = 0 xml.responseText = 无

标签: asp.net web-services


【解决方案1】:

需要在 Web 服务中启用脚本服务执行。像这样:

[ScriptService]

【讨论】:

    猜你喜欢
    • 2011-04-07
    • 1970-01-01
    • 2016-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-04
    相关资源
    最近更新 更多