Completed
Last Updated: 15 Jun 2020 13:38 by ADMIN
GDPR_erased
Created on: 09 Jun 2020 06:47
Category: ComboBox
Type: Bug Report
0
RadComboBox WebServiceSettings 500 error.
I believe there's a bug in the RadComboBox WebServiceSettings tag. I use a webservice to populate the items for this RadComboBox

When I put in a fully qualified domain name in the property 'Path' and the hostname contains uppercase characters, I receive a 500 error. If the hostname is in lowercase, the items are populated correctly. The error is: Uncaught TypeError: Cannot read property 'webServiceFailedNoMsg' of undefined.

I've enclosed the Webservice1.asmx, the Default.aspx and their code behind files which can illustrate the problem very easily. There's also a log file with the details of the error.
Attached Files:
1 comment
ADMIN
Peter Milchev
Posted on: 15 Jun 2020 13:38

Hello Arjan,

Thank you for sharing the reproduction code. 

I have tested this and the following non-Telerik related code has the same issue:

<input type="text" name="hostname" id="hostname" value="LOCALHOST:63527" />
<button type="button" onclick="OnClientClicked()">Make a Request</button>
<script>
    function OnClientClicked() {
        var params = {
            "context": {
                "Text": "",
                "NumberOfItems": 0,
                "FilterString": ""
            }
        }
        var url = "http://" + document.getElementById("hostname").value + "/WEBSERVICE1.asmx";

        Sys.Net.WebServiceProxy.invoke(url, "LoadAutoCompleteNodesComboBox", true, params,
            function success() {
                console.log("success");
                alert("success")
                console.log(arguments)
            }, function error() {
                console.log("error");
                alert("error")
                console.log(arguments)
            }, "");
    }
</script>

It seems in some cases the hostname is case sensitive, although the documentation does not explicitly say it can be only lowercase: 

To be absolutely correct, the issue stems from the way how the MSAJAX framework works and how it determines if the request is a JSONP or not.

Below you can find the beginning of the Sys.Net.WebServiceProxy.invoke function:

Sys.Net.WebServiceProxy.invoke = function Sys$Net$WebServiceProxy$invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout, enableJsonp, jsonpCallbackParameter) {
    /// <summary locid="M:J#Sys.Net.WebServiceProxy.invoke" />
    /// <param name="servicePath" type="String"></param>
    /// <param name="methodName" type="String" mayBeNull="true" optional="true"></param>
    /// <param name="useGet" type="Boolean" optional="true"></param>
    /// <param name="params" mayBeNull="true" optional="true"></param>
    /// <param name="onSuccess" type="Function" mayBeNull="true" optional="true"></param>
    /// <param name="onFailure" type="Function" mayBeNull="true" optional="true"></param>
    /// <param name="userContext" mayBeNull="true" optional="true"></param>
    /// <param name="timeout" type="Number" optional="true"></param>
    /// <param name="enableJsonp" type="Boolean" optional="true" mayBeNull="true"></param>
    /// <param name="jsonpCallbackParameter" type="String" optional="true" mayBeNull="true"></param>
    /// <returns type="Sys.Net.WebRequest" mayBeNull="true"></returns>
    var e = Function._validateParams(arguments, [
        { name: "servicePath", type: String },
        { name: "methodName", type: String, mayBeNull: true, optional: true },
        { name: "useGet", type: Boolean, optional: true },
        { name: "params", mayBeNull: true, optional: true },
        { name: "onSuccess", type: Function, mayBeNull: true, optional: true },
        { name: "onFailure", type: Function, mayBeNull: true, optional: true },
        { name: "userContext", mayBeNull: true, optional: true },
        { name: "timeout", type: Number, optional: true },
        { name: "enableJsonp", type: Boolean, mayBeNull: true, optional: true },
        { name: "jsonpCallbackParameter", type: String, mayBeNull: true, optional: true }
    ]);
    if (e) throw e;
    var schemeHost = (enableJsonp !== false) ? Sys.Net.WebServiceProxy._xdomain.exec(servicePath) : null,
        tempCallback, jsonp = schemeHost && (schemeHost.length === 3) &&
            ((schemeHost[1] !== location.protocol) || (schemeHost[2] !== location.host));
    useGet = jsonp || useGet;
    if (jsonp) {
        jsonpCallbackParameter = jsonpCallbackParameter || "callback";
        tempCallback = "_jsonp" + Sys._jsonp++;
    }

In the highlighted area the schemeHost[2] is "LOCALHOST:63527" while location.host is "localhost:63527". Comparing the two strings returns false and the MSAJAX framework assumes this is a JSONP request and invokes the wrong request. 

With that said, you can choose one of the following approaches:

1) Use lowercase hostnames. The method name is case insensitive.

2) Override the get_path method of the WebServiceSettings to return a lowercase path by placing the following script under the script manager

 

Telerik.Web.UI.WebServiceSettings.prototype.get_path = function () {
    return this._path.toLowerCase();
}

 

3) Override the MSAJAX framework's Sys.Net.WebServiceProxy.invoke method to take into account the case when validating:

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.