Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>.NET 3.5 has support built-in. For .NET 2.0, extra libraries are needed. I used the Jayrock library.</p> <p>I recently delivered an application that uses pure Javascript at the browser (viz. using AJAX technology, but not using Microsoft AJAX or Scriptaculous etc) which marries up to Microsoft webservices at the back end. When I started writing this I was new to the world of .NET, and felt overwhelmed by all the frameworks out there! So I had an urge to use a collection of small libraries rather than very large frameworks.</p> <p>At the javascript application, I call a web service like this. It directly reads the output of the web service, cuts away the non JSON sections, then uses <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="nofollow noreferrer">https://github.com/douglascrockford/JSON-js/blob/master/json2.js</a> to parse the JSON object.</p> <p>This is not a standard approach, but is quite simple to understand, and may be of value to you, either to use or just to learn about webservices and JSON.</p> <pre><code>// enclosing html page has loaded this: &lt;script type="text/javascript" src="res/js/json2.js"&gt;&lt;/script&gt; // Invoke like this: // var validObj = = callAnyWebservice("WebServiceName", ""); // if (!validObj || validObj.returnCode != 0) { // alert("Document number " + DocId + " is not in the vPage database. Cannot continue."); // DocId = null; // } function callAnyWebservice(webserviceName, params) { var base = document.location.href; if (base.indexOf(globals.testingIPaddr) &lt; 0) return; gDocPagesObject=null; var http = new XMLHttpRequest(); var url = "http://mywebserver/appdir/WebServices.asmx/" + webserviceName; //alert(url + " " + params); http.open("POST", url, false); http.setRequestHeader("Host", globals.testingIPaddr); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.setRequestHeader("Content-Length", params.length); // http.setRequestHeader("Connection", "close"); //Call a function when the state changes. http.onreadystatechange = function() { if (http.readyState == 4 ) { if (http.status == 200) { var JSON_text = http.responseText; var firstCurlyQuote = JSON_text.indexOf('{'); JSON_text = JSON_text.substr(firstCurlyQuote); var lastCurlyQuote = JSON_text.lastIndexOf('}') + 1; JSON_text = JSON_text.substr(0, lastCurlyQuote); if (JSON_text!="") { //if (DEBUG) // alert(url+" " +JSON_text); gDocPagesObject = eval("(" + JSON_text + ")"); } } else if (http.readyState == 4) {alert(http.readyState + " " + http.status + " " + http.responseText)} } } http.send(params); if (gDocPagesObject != null) { //alert(gDocPagesObject.returnCode + " " + gDocPagesObject.returnString); return gDocPagesObject; } else return "web service unavailable: data not ready"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload