transport update -> webservice issue

4 posts, 0 answers
  1. Bob
    Bob avatar
    7 posts
    Member since:
    Jul 2015

    Posted 22 Jul 2015 Link to this post

    Not sure if this is a vb.net or datasource issue but am trying here.

    I'm using vb.net and am having an issue when i try to ​send the updated data back to the server. I've found there to be a number of idiosyncrasies with connecting to .net so perhaps this is another one.

    When I try to receive the data, it says it the method name isn't valid only when I try to assign the data to a variable. For example ​I'm able to send along a parameter to one function with an Int. And I can call the update function with no receiving parameter, but when I try to send along the data object it fails.

    VB.Net code:
    Works when accepting an int.
     

     <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function GetFullRecords(projectID as Integer) As List(Of fullRecords)
           return loadFullRecords(loadMonths(projectID), loadHeaders(projectID) ,  loadDetails(projectID) )
     End Function

    And the broken one works fine if I don't accept anything

    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function UpdateFullRecords() As String 
       return "​gotData"
    End Function 

     

    But as soon as I try to accept those records it fails

    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function UpdateFullRecords(models as List(of fullRecords) ) As String 
       return "​gotData"
    End Function 


    System.InvalidOperationException: UpdateFullRecords Web Service method name is not valid.

    Datasource code:

        dataSource = new kendo.data.DataSource(    {
            transport: {
                read:  {
                    url: baseUrl + "gridData.asmx/GetFullRecords",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    headers: {"Accept": "application/json"}
                },
                update: {
                    url: baseUrl + "gridData.asmx/UpdateFullRecords",
                    type: "POST",
                    dataType: "json"
                   headers: {"Accept": "application/json"}
                },
                parameterMap: function(options, operation) {
                    if(operation === "read")
                        var values = {projectID: 32};
                       return kendo.stringify(values);
                    } else if (operation !== "read" && options.models) {
                        console.log("Not Read - " + operation);
                        return{fullRecords:  kendo.stringify(options.models)};
                    }
                }
            },
            schema: {
                parse: function (data) {
                    return data.d;
                },
                model: {
                    id: "headerID",
                    fields: mySchemaFields
                }
            }
       });

    Attached images from firebug showing that the data looks to be the same.  So not sure why it can find the method in one instance and not the other.

     

  2. Bob
    Bob avatar
    7 posts
    Member since:
    Jul 2015

    Posted 23 Jul 2015 in reply to Bob Link to this post

    The problem looks like it was revolving around not stringifying the right information in the parameter map.  I made a very simple 2 file example which doesn't do much beyond test sending and receiving data.

     Here is my z_exampleCity.asmx file

    <%@ WebService Language="vb"   Class="z_exampleCity" %>
     
    Imports System.Web
    Imports System.Web.SessionState
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.Web.Script.Services
    Imports System.Collections.Generic
    Imports System.Linq
     
    Public Class City
        Public cityID as Integer
        Public population as Integer
        Public name as String
    End Class
     
     
    <WebService(Namespace:="http://tempuri.org/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ScriptService()> _
    Public Class z_exampleCity
        Inherits System.Web.Services.WebService
     
        <System.Web.Services.WebMethod(EnableSession:=True)>  _
        <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
        Public Function GetCities(numCities as Integer) As List(Of City)
            dim cList as New List(Of City)
            For i = 0 to numCities
                Dim cItem as New City
                cItem.cityID = i
                cItem.name = "City number " + i.ToString()
                cItem.population = i * 1778
                cList.Add(cItem)
            Next i
             
            return cList
        End Function
         
        <System.Web.Services.WebMethod(EnableSession:=True)>  _
        <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
        Public Function UpdateCities( city as  List(Of City)) As List(Of City)
            dim x as Integer = 11
         
            dim cList as New List(Of City)
            Dim cItem as New City
            cItem.cityID =  x
            cItem.name = "Update number " +  x.ToString()
            cItem.population =  x * 1778 + 111
            cList.Add(cItem)
             
            return cList
        End Function
     
    End Class

     And here is the .aspx page

    <%@ Page Language="VB" Debug="true" EnableSessionState="True"   AutoEventWireup="false"%>  
    <!DOCTYPE HTML>
    <html>
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="icon" href="favicon.ico" type="image/icon">
    <title> </title>
        <link rel="stylesheet" href="./kendo/styles/kendo.common-material.min.css" />
        <link rel="stylesheet" href="./kendo/styles/kendo.material.min.css" />
        <script src="./kendo/js/jquery.min.js"></script>
        <script src="./kendo/js/kendo.all.min.js"></script>
     
    <script type="text/javascript">
    $(document).ready(function () {
        var columnList = [
            { field: "cityID", title: "cityID"},
            { field: "name", title: "name"},
            { field: "population", title: "population"}
        ];
        var mySchemaFields = {
            cityID: { editable: false},
            name: { editable: false},
            population: { editable: true }
        };
     
        var crudServiceBaseUrl = "./",
        dataSource = new kendo.data.DataSource({
            transport: {
                read:  {
                    url: crudServiceBaseUrl + "z_exampleCity.asmx/GetCities",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    headers: {"Accept": "application/json"}
                },
                update: {
                    url: crudServiceBaseUrl + "z_exampleCity.asmx/UpdateCities",
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    headers: {"Accept": "application/json"}
                },
                parameterMap: function(options, operation) {
                    if(operation === "read"){
                        var values = {numCities: 8};  /* Proof that you can send and read simple parameters*/
                        return kendo.stringify(values);
                         
                    } else if (operation !== "read" && options.models) {
                        var values = {city: options.models}  /*only strinfigy once on the complete object. /*
                        return  kendo.stringify(values);
                    }
                }
            },
            batch: true,
            pageSize: 20,
            schema: {
                parse: function (data) {
                    return data.d;
                },
                model: {
                    id: "cityID",
                    fields: mySchemaFields
                }
            }
        });
         
        $("#grid").kendoGrid({
                dataSource: dataSource,
                editable: true,
                batch: true,
                toolbar: ["save", "cancel"],
                scrollable: true,
                navigatable: true,
                height: 600,
                columns: columnList
        });
    });
    </script>
    </head>
    <body>
        <div id="grid"></div>
    </body>
    </html>

  3. Kendo UI is VS 2017 Ready
  4. Bob
    Bob avatar
    7 posts
    Member since:
    Jul 2015

    Posted 23 Jul 2015 in reply to Bob Link to this post

    Issue is resolved - don't see a way to edit prior posts or the title to make it clear.
  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 24 Jul 2015 Link to this post

    Hello Bob,

    I am glad to hear that you managed to resolve the issue. I will mark this thread as resolved and will close it.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready