Results 1 to 7 of 7

Thread: OMG - I can't believe I can do this with a WEB SERVICE!!

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Lightbulb OMG - I can't believe I can do this with a WEB SERVICE!!

    I have died and gone to heaven.

    Look at this web service declaration!

    Code:
        <WebMethod()> _
        <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)> _
        Public Function SaveService(ByVal toddtype As String, ByVal fromddtype As String
                                  , ByVal fromwho As String, ByVal VisitId As Integer
                                  , ByVal objReturn As Dictionary(Of String, String)) As String
    Guess what objReturn is!!!!

    It's the original JSON recordset retained as an object in javascript simply passed back and it's now a pair'd up dictionary object for me to bind to my update sproc in a loop!!
    Attached Images Attached Images  

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: OMG - I can't believe I can do this with a WEB SERVICE!!

    Thanks very much for posting that. Makes passing json back and forth a breeze. I'm going to have a good play around with some jquery/ajax stuff.
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  3. #3

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: OMG - I can't believe I can do this with a WEB SERVICE!!

    I had not even considered sending JSON to the browser with this - I guess it never gets converted to "text" JSON that I have to see - maybe it doesn't have all those evil quote and value formatting rules.

    I was so happy to be able to have a "dynamic" amount of parameters to a VB function call that I can't contain myself!

    I'm mapping them to a SPROC with a loop that finds out the SPROC parameter names and simply binds them to that dictionary object.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: OMG - I can't believe I can do this with a WEB SERVICE!!

    Interesting, I did not know that you could do that.

    Are you having to use any JavaScript libraries on the client to "format" the JSON to pass into the Web Service method, or is that just straight out the box?

    Gary

  5. #5

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: OMG - I can't believe I can do this with a WEB SERVICE!!

    Quote Originally Posted by gep13 View Post
    Interesting, I did not know that you could do that.

    Are you having to use any JavaScript libraries on the client to "format" the JSON to pass into the Web Service method, or is that just straight out the box?

    Gary
    No that is a totally unformatted "straight out of memory" raw JS object. No double quotes required - none of that MS ajax asp.net extra rules.

    Oddly when I go to visit the web service "page" it tells me it does not support iDictionary formats - but it works.

    But now I'm looking into WCF instead of raw services like this so I might lose this nice feature.

    I still have not got a straight answer on whether straight web services with POST only on HTTPS are secure out of the box...

    [edit] - it is part of a STRING formatted json

    Code:
    function saveClick(event) {
        var strPanel = "#" + this.parentNode.parentNode.id;
        var objWebParam = {};
        restoreWebParam(this, objWebParam);
        objWebParam.objReturn.VisitDate = $(strPanel + " .awc-VisitDate").val();
        objWebParam.objReturn.VisitTimeIn = $(strPanel + " .awc-VisitTimeIn").val();
        objWebParam.objReturn.ReturnClass = $(strPanel + " .awc-ReturnClass").val();
        objWebParam.objReturn.Dismissed = $(strPanel + " .awc-Dismissed").val();
        objWebParam.objReturn.DismissNote = $(strPanel + " .awc-DismissNote").val();
        objWebParam.objReturn.PrimaryComplaint = $(strPanel + " .awc-PrimaryComplaint").val();
        objWebParam.objReturn.Period = $(strPanel + " .awc-Period").val();
        objWebParam.objReturn.Temp = $(strPanel + " .awc-Temp").val();
        objWebParam.objReturn.BP = $(strPanel + " .awc-BP").val();
        objWebParam.objReturn.Pulse = $(strPanel + " .awc-Pulse").val();
        var strWebParam = $.toJSON(objWebParam);
        $.ajax({
            type: "POST",
            url: "WebService.asmx/SaveService",
            dataType: "json",
            data: strWebParam,
            contentType: "application/json; charset=utf-8",
            success: function(msg) {
                updateSaveFinished(msg, strPanel, objWebParam);
            },
            failure: function(msg) {
                updateSaveFinished(msg, "failure", objWebParam);
            },
            error: function(msg) {
                updateSaveFinished(msg, "error", objWebParam);
            }
        });
    }
    [/edit]
    Last edited by szlamany; Apr 21st, 2011 at 07:37 AM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: OMG - I can't believe I can do this with a WEB SERVICE!!

    omg2

    Code:
    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)> _
    Public Function SaveService(ByVal toddtype As String, ByVal fromddtype As String
                                , ByVal fromwho As String _
                                , ByVal source As IList(Of Dictionary(Of String, String))
                                , ByVal objReturn As Dictionary(Of String, String)) As String
    Note the "source" as IList of Dictionary...

    Guess what that is!

    JS Array of Objects!

    Filled with this in the JS source

    Code:
    objWebParam.source = g_arrSource[intGO];
    And that is the SOURCE of the SLICKGRID data

    After hours of web searching the rule is:

    JS Array is IList
    JS Object is Dictionary
    Attached Images Attached Images  

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: OMG - I can't believe I can do this with a WEB SERVICE!!

    that's awesome. Great work you have some really good stuff on your project

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width