1 Attachment(s)
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!!
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.
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.
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
Re: OMG - I can't believe I can do this with a WEB SERVICE!!
Quote:
Originally Posted by
gep13
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]
1 Attachment(s)
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
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