Posting Registration Data to Remote Server

3 posts, 0 answers
  1. Alok Tibrewal
    Alok Tibrewal avatar
    2 posts
    Member since:
    Mar 2005

    Posted 27 Mar 2012 Link to this post

    Hi Team,

           var objLogin = new Object();
           objLogin.LoginNm = "abc@siplnet.com"
           objLogin.Password = "abcdef"
     
           function fn_Login() {
                scmEventTypeList = {
                    model: {}
                };
     
                dsUsrList = kendo.data.DataSource.create({
                    schema: scmEventTypeList,
                    transport: {
                        read: {
                            url: ServiceUrl,
                            contentType: "application/json; charset=utf-8",
                            dataType: "jsonp"
                        },
                        parameterMap: function(options) {                                      
                            return JSON.stringify(objLogin);    
                        }
                    },
                    error: function () { alert("Error"); }
                });
     
                $("#ulUsrInfo").kendoMobileListView({
                    dataSource: dsUsrList,
                    template: $("#TmpUser").html()
                });
            }

    I am trying to post registration information to the remote web service. I am not sure what is going wrong here. My Webservice works fine if I use normal ajax method to post.

    Any assistance in this is highly appriciated.

  2. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 27 Mar 2012 Link to this post

    Do you have this in your Web Service. Please note the Script Methods and the
    first Rem line
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    <System.Web.Script.Services.ScriptService()> _
     by default it is like this 
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    '<System.Web.Script.Services.ScriptService()> _


    Imports System.Web.Script.Services
    Imports System.Web.Script.Serialization
     
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    <System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ToolboxItem(False)> _
    Public Class DSR
    Inherits System.Web.Services.WebService
     
    <WebMethod(EnableSession:=True)> _
        <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
    public function DoSomething(byval str as string) as string
    return str
    end function
     
    end class
  3. Kendo UI is VS 2017 Ready
  4. Alok Tibrewal
    Alok Tibrewal avatar
    2 posts
    Member since:
    Mar 2005

    Posted 28 Mar 2012 Link to this post

    Hi 

    We are using WCF Service. In below i attached one of my POST method function which is unable to reach from our Test Kendo App. 

    IService.vb
    ------------------------------------------
        <OperationContract()> _
        <WebInvoke(Method:="POST", RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="/ValidateUsr2/{Login}")> _
        Function ValidateUsr2(ByVal Login As dtoLogin) As IList(Of dtoUsr)

    Service.vb
    ------------------------------------------
        Function ValidateUsr2(ByVal Login As dtoLogin) As IList(Of dtoUsr) Implements IService.ValidateUsr2
            Dim dUsr As IList(Of dtoUsr) = Nothing
            Try
                CreateTxnClass()
                clsTxnMgnServer.ValidateUsr2_Proc(Login, dUsr)
            Catch ex As Exception
                m_csLog &= "WebService: Error - " & ex.Message & vbNewLine
            Finally
                FinalizeTxnClass()
            End Try
            Return dUsr
        End Function
    ------------------------------------------
    We call this service function from our kendo test app.
    ------------------------------------------
    <body onload="onLoad">
        <div data-role="layout" data-id="default">
            <header data-role="header">
            <div data-role="navbar">
                <span data-role="view-title"></span>
            </div>
            </header>
            <footer data-role="footer" data-id="default">
            <div data-role="tabstrip">
                <a href="#Login" data-icon="contacts">Login</a>
                <a href="#NewUsr" data-icon="contacts">New User</a>
            </div>
            </footer>
        </div>
        <div data-role="view" data-title="Login" id="Login" data-init="fn_Login2">
            <ul id="ulUsrInfo">
            </ul>
        </div>
        <script type="text/x-kendo-template" id="TmpUser">
        <h4 class="item-title">${FirstName}</h4>
        </script>
        <script>
            var ServiceUrl = "http://192.168.1.7/MTServices/Service.svc/";
            var Login = new Object();
            Login.LoginNm = "abc@siplnet.com"
            Login.Password = "abc"


            function fn_Login2() {
                var LoginUrl = ServiceUrl + "ValidateUsr2/";
                scmEventTypeList = {
                    model: {}
                };


                dsUsrList = kendo.data.DataSource.create({
                    transport: {
                        create: {
                            type: "POST",
                            url: LoginUrl,
                            data: Login,
                            dataType: "jsonp"
                        },
                        parameterMap: function (data) {
                            return JSON.stringify(data);
                        },
                        schema: scmEventTypeList
                    },
                    error: function () { alert("Error"); }
                });


                $("#ulUsrInfo").kendoMobileListView({
                    dataSource: dsUsrList,
                    template: $("#TmpUser").html()
                });
            }


        </script>
        <script>
            window.kendoMobileApplication = new kendo.mobile.Application($(document.body), { layout: "default", transition: "slide" });
        </script>
    </body>
    ------------------------------------------
    Error: Unable to get value of the property 'data': object is null or undefined
    ------------------------------------------

    service function which are without any parameter and GET only --- its working fine. But while i passing any data to the remote server via jsonp -- its giving error.

    Thanks 

    Alok
Back to Top