public static void AddParameter(InternalWebMethodRequest that, string name, string value) { if (null == value) return; var key = "_" + that.MetadataToken + "_" + name; //Console.WriteLine("AddParameter " + new { key, value }); //Console.WriteLine("InternalWebMethodRequest.AddParameter " + new { key, value }); that.InternalUploadValues[key] = value.ToXMLString(); //if (string.IsNullOrEmpty(that.Data)) //{ // that.Data = ""; //} //else //{ // that.Data += "&"; //} //// http://stackoverflow.com/questions/81991/a-potentially-dangerous-request-form-value-was-detected-from-the-client //var __value = value.ToXMLString(); //// http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp //var evalue = Native.window.escape(__value).Replace("+", "%" + ((byte)'+').ToString("x2")); ////Console.WriteLine( //// new { name, __value, evalue } ////); //that.Data += "_" + that.MetadataToken + "_" + name + "=" + evalue; }
public static void AddParameter(InternalWebMethodRequest that, string name, string value) { if (null == value) { return; } var key = "_" + that.MetadataToken + "_" + name; //Console.WriteLine("AddParameter " + new { key }); that.InternalUploadValues[key] = value.ToXMLString(); //if (string.IsNullOrEmpty(that.Data)) //{ // that.Data = ""; //} //else //{ // that.Data += "&"; //} //// http://stackoverflow.com/questions/81991/a-potentially-dangerous-request-form-value-was-detected-from-the-client //var __value = value.ToXMLString(); //// http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp //var evalue = Native.window.escape(__value).Replace("+", "%" + ((byte)'+').ToString("x2")); ////Console.WriteLine( //// new { name, __value, evalue } ////); //that.Data += "_" + that.MetadataToken + "_" + name + "=" + evalue; }
public static string GetInternalFieldValue(InternalWebMethodRequest that, string FieldName) { //Console.WriteLine("enter GetInternalFieldValue " + new { FieldName }); var FieldValue = default(string); if (that == null) { FieldValue = InternalFieldsFromTypeInitializer[FieldName]; } else { FieldValue = that.InternalFields[FieldName]; } // X:\jsc.svn\examples\javascript\test\TestNullObjectFromWebService\TestNullObjectFromWebService\Application.cs //Console.WriteLine("exit GetInternalFieldValue " + new { FieldName, FieldValue }); return(FieldValue); }
public static void Invoke(InternalWebMethodRequest that) { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151123/uploadvaluestaskasync // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/20150301 // Z:\jsc.svn\examples\javascript\Test\TestAfterInvokeResponseHeaders\ApplicationWebService.cs //Console.WriteLine("InternalWebMethodRequest.Invoke " + new { that.Name }); //var x = new IXMLHttpRequest(); // we are using // "xml" as path // "WebMethod" as method selector // we could hide those details into post. // what about generic methods // X:\jsc.svn\examples\javascript\svg\SVGNavigationTiming\SVGNavigationTiming\Application.cs // http://xhr.spec.whatwg.org/ // X:\jsc.svn\examples\javascript\Test\TestWebMethodIPAddress\TestWebMethodIPAddress\ApplicationWebService.cs // will this help us? // IE will thow InvalidStateError //x.withCredentials = true; ////x.open(HTTPMethodEnum.POST, Target); ////// http://stackoverflow.com/questions/12072315/uncaught-error-invalid-state-err-dom-exception-11 ////x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); ////x.send( //// globalscl::ScriptCoreLib.JavaScript.BCLImplementation.System.Net.__WebClient.ToFormDataString( //// that.InternalUploadValues //// ) ////); ////x.InvokeOnComplete(that.Complete, 50); that.InternalUploadValues["WebMethodMetadataToken"] = that.MetadataToken; that.InternalUploadValues["WebMethodMetadataName"] = that.Name; // do we have a previous etag available? if (MetadataTokenToETagLookup.ContainsKey(that.MetadataToken)) { // send in the etag to get 304. that.InternalUploadValues["ETag"] = Convert.ToBase64String(MetadataTokenToETagLookup[that.MetadataToken]); } //var Target = "/xml?WebMethod=" + that.MetadataToken + "&n=" + that.Name; // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201401/20140110-xml // description? var Target = "/xml/" + that.Name; // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/20150301 //Console.WriteLine("InternalWebMethodRequest.Invoke WebClient UploadValuesAsync"); var w = new __WebClient(); // can we use await here? w.UploadValuesTaskAsync( new Uri(Target, UriKind.Relative), that.InternalUploadValues ).ContinueWith( t => { //Console.WriteLine("InternalWebMethodRequest.Invoke complete " + new { that.Name }); //if (args.Error != null) //{ // //t.text = "UploadValuesCompleted error " + new { args.Error }.ToString(); // return; //} // DownloadStringAsync { Length = 2822 } //var data = Encoding.UTF8.GetString(args.Result); // does this work in android webview? that.Complete(t.Result, w); } ); }
public static string GetInternalFieldValue(InternalWebMethodRequest that, string FieldName) { //Console.WriteLine("enter GetInternalFieldValue " + new { FieldName }); var FieldValue = default(string); if (that == null) { FieldValue = InternalFieldsFromTypeInitializer[FieldName]; } else { FieldValue = that.InternalFields[FieldName]; } // X:\jsc.svn\examples\javascript\test\TestNullObjectFromWebService\TestNullObjectFromWebService\Application.cs //Console.WriteLine("exit GetInternalFieldValue " + new { FieldName, FieldValue }); return FieldValue; }