Saya telah berhubungan dengan layanan web untuk waktu yang lama, tetapi tidak banyak tutorial untuk menggunakan ASP untuk dihubungi, dan tidak umum untuk dikonversi ke JSON.
Pertama -tama tentukan data SOAP, lalu buat objek HTTP, lalu kirimkan menggunakan POST, dan dapatkan kode status 200, yang berarti panggilan berhasil, dan kemudian lanjutkan ke operasi berikutnya ...
Lihatlah kode implementasi tertentu
<!-#Sertakan virtual =/include/json.min.asp-> <%redup strxmldim str'definition pesan sabun strxml = <? Xml versi = '1.0' encoding = 'UTF-8'?> Strxml = strxml & <SOAP: amplop xmlns: xsi = 'http: //www.w3.org/2001/xmlschema-instance' xmlns: xsd = 'http: //www.w3.org/2001/xmlschema' xmlns: sabun = ' http://schemas.xmlsoap.org/soap/envelope/ '> strxml = strxml & <SOAP: BODY> strxml = strxml & <getCategories xmlns = 'http: //tempuri.org/'> strxml = strxml & <reqcode> 30000001 </reqcode> 'Parameter 1Strxml = strxml & <Sign> SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS SSSS Sss Sss Sss Sss SS 'Parameter 2StrXml = strxml & </getCategories> strxml = strxml & </soap: body> strxml = strxml & </soap: envelope> set h = createObject (microsoft.xmlhttp)' Kirim pesan pos h.open ke URL yang ditentukan POS, http://www.domain.com/webservice.asmx, falseh.setrequestheader konten-tipe, teks/xml; .org/getCategoriessh.send (strxml) 'Tampilkan informasi XML yang dikembalikan jika h.status = 200 lalu set xmldoc = server.createObject (msxml.domdocument) xmldoc.load (h.responsexml) jsontext = xmldoc.childnodes (1) .text 'Convert ke json, hubungi json.min.asp set kategori = json.parse (jsontext) untuk i = 0 ke kategori.length -1 response.write (cstr (kategori.get (catget (cattegori i) .categoryName)) 'properti untuk j = 0 ke kategori.get (i) .labels.length - 1' collection response.write (cstr (kategori.get (i) .labels.get (j) .labelName)) Berikutnya Berikutnya <Nama Pra = Kode Kelas = VB> <Script bahasa = javaScript runat = server> if (! array.prototype.get) {array.prototype.get = function (prop) {return ini [prop];}} Gunakan strict; if (! this.json) {json = { };} (function () {function f (n) {return n <10? '0'+n: n;} if (typeof date.prototype.toJson! == 'function') {date.prototype.toJson = function (key) {return isFinite (this.ValueOf ())? this.getutclyear ()+'-'+f (this.getUtcmonth ()+1)+'-'+f (this.getutcdate ())+'t'+f (ini .getutchours ())+':'+f (this.getUtcminutes ())+':'+f (this.getutcseconds ())+'z': null;}; string.prototype.toJson = number.prototype. TOJSON = boolean.prototype.toJson = function (key) {return this.valueof ();};} var cx =/[/?/?/?-/?/?/?/?/?-/?/?-/?/?-/?/?-/?/?-/?/?-/?] /g, dapat dilepas =/[//// x00-/x1f/x7f-/x9f/?/?-/?/?/?/?/?/?-/?-/?/?-/?/? -/?/?-/?/?-/?/?-/?]/g, gap, indent, meta = {'/b': '// b', '/t': '// t' , '/n': '// n', '/f': '// f': '// f', '/r': '// r', '': '//', '// /':' /// '}, rep; function quote (string) {Escapable.LastIndex = 0; return Ecapable.test (String)? ''+String.replace (Eccapable, function (a) {var c = meta [a]; return typeof c === 'string'? c: '// u'+('0000 '+a.charcodeat (0) .toString (16)). slice (-4);})+' ':' '+string+';} fungsi str (tombol, pemegang) {var i, k, v, length, mind = gap, parsial, value = holder [key]; if (value && typeOf value === 'objek' && typeof value.toJson === 'function') {value = value.toJson (key);} if (typeof rep === 'function') {value = rep.call (holder, key, value);} switch (typeof value) {case'string ': return quote (value); case'number': return isFinite (value)? String (value): 'null'; case'boolean ': case'null': return String (value); case'Object ': if (! Value) {return'null';} gap+= indent; parsial = []; if (object.prototype.toString.Apply (value) === '[objek Array] ') {length = value.length; for (i = 0; i <length; i+= 1) {parsial [i] = str (i, value) ||' null ';} v = parsial.length = == 0? '[]': Celah? '[/N'+celah+parsial.join (',/n'+celah)+'/n'+pikiran+']': '['+parsial.noin ( ',')+']'; gap = mind; return v;} if (rep && typeOf rep === 'objek') {length = rep.length; for (i = 0; i <length; i+= 1) { k = rep [i]; if (typeof k === 'string') {v = str (k, nilai); if (v) {parsial.push (quote (k)+(celah? ':': ':')+v);}}}} } else {for (k in value) {if (object.hasownproperty.call (value, k)) {v = str (k, value); if (v) {parsial.push (quote (k)+(celah? ': ':': ')+v);}}}}} v = parsial.length === 0?' {} ': celah?' {/n '+celah+parsial.join (',/n '+ gap)+'/n'+mind+'}': '{'+parsial.join (',')+'}'; gap = mind; return v;}} if (typeof json.stringify! == 'fungsi' ') {Json.stringify = function (value, replacer, space) {var i; gap =' '; indent =' '; if (typeof space ===' nomor ') {for (i = 0; i <spasi ; i+= 1) {indent+= ' ';}} lain jika (typeof space ===' string ') {indent = space;} rep = replacer; if (replacer && typeof replacer! ==' function '&& (typeof replacer! ==' objek '|| typeof Replacer .length! == 'number')) {throw new error ('json.stringify');} return str ('', {'': value});};} if (typeof json.parse! == ' function ') {json.parse = function (text, reviver) {var j; function walk (holder, key) {var k, v, value = holder [key]; if (value && typeOf value === 'objek') {for (k in value) {if (object.hasownproperty.call (value, k) ) {v = walk (value, k); if (v! == tidak terdefinisi) {value [k] = v;} else {hapus nilai [k];}}}} return reviver.call (holder, key, value);} cx.LastIndex = 0; if (cx.test (text)) {text = text.replace (cx, function (a) {return '// u'+(' 0000 '+a.charcodeat (0) .toString (16)). Slice (-4);});} if (/^[/] ,: {}/s]*$/. Test (teks. ganti (/// (?: [//// bfnrt] | u [0-9a-fa-f] {4})/g, '@'). Ganti (/[^/// n/r] *| true | false | null |-?/d+(?: /./ d*)? (?: [ee] [+/-]?/d+)?/g, ']'). Ganti (/( ?:^|: |,) (?:/s*/[)+/g, ''))) {j = eval ('('+text+')'); return typeOf reviver === 'function'? walk ({'': j}, ''): j;} lempar sintakser baru ('json.parse');};}} ()); </skrip> set xmldoc = noleelse response.write h.status & response.write h.statustextend if%> Lampiran: json.min.asp <script language = javascript runat = server> if (! array.prototype.get) {array.prototype.get = function (prop) {return ini [prop];}} Gunakan strict; if (! this.json) {json = {};} (function () {function f (n) {return n <10? '0'+n: n;} if (typeof date.prototype.toJson! == 'function') {date.prototype. TOJSON = function (key) {return isFinite (this.ValueOf ())? this.getutclyear ()+'-'+f (this.getUtcmonth ()+1)+'-'+f (this.getutcdate ())+'t'+f (ini .getutchours ())+':'+f (this.getUtcminutes ())+':'+f (this.getutcseconds ())+'z': null;}; string.prototype.toJson = number.prototype. TOJSON = boolean.prototype.toJson = function (key) {return this.valueof ();};} var cx =/[/?/?/?-/?/?/?/?/?-/?/?-/?/?-/?/?-/?/?-/?/?-/?] /g, dapat dilepas =/[//// x00-/x1f/x7f-/x9f/?/?-/?/?/?/?/?/?-/?-/?/?-/?/? -/?/?-/?/?-/?/?-/?]/g, gap, indent, meta = {'/b': '// b', '/t': '// t' , '/n': '// n', '/f': '// f': '// f', '/r': '// r', '': '//', '// /':' /// '}, rep; function quote (string) {Escapable.LastIndex = 0; return Ecapable.test (String)? ''+String.replace (Eccapable, function (a) {var c = meta [a]; return typeof c === 'string'? c: '// u'+('0000 '+a.charcodeat (0) .toString (16)). slice (-4);})+' ':' '+string+';} fungsi str (tombol, pemegang) {var i, k, v, length, mind = gap, parsial, value = holder [key]; if (value && typeOf value === 'objek' && typeof value.toJson === 'function') {value = value.toJson (key);} if (typeof rep === 'function') {value = rep.call (holder, key, value);} switch (typeof value) {case'string ': return quote (value); case'number': return isFinite (value)? String (value): 'null'; case'boolean ': case'null': return String (value); case'Object ': if (! Value) {return'null';} gap+= indent; parsial = []; if (object.prototype.toString.Apply (value) === '[objek Array] ') {length = value.length; for (i = 0; i <length; i+= 1) {parsial [i] = str (i, value) ||' null ';} v = parsial.length = == 0? '[]': Celah? '[/N'+celah+parsial.join (',/n'+celah)+'/n'+pikiran+']': '['+parsial.noin ( ',')+']'; gap = mind; return v;} if (rep && typeOf rep === 'objek') {length = rep.length; for (i = 0; i <length; i+= 1) { k = rep [i]; if (typeof k === 'string') {v = str (k, nilai); if (v) {parsial.push (quote (k)+(celah? ':': ':')+v);}}}} } else {for (k in value) {if (object.hasownproperty.call (value, k)) {v = str (k, value); if (v) {parsial.push (quote (k)+(celah? ': ':': ')+v);}}}}} v = parsial.length === 0?' {} ': celah?' {/n '+celah+parsial.join (',/n '+ gap)+'/n'+mind+'}': '{'+parsial.join (',')+'}'; gap = mind; return v;}} if (typeof json.stringify! == 'fungsi' ') {Json.stringify = function (value, replacer, space) {var i; gap =' '; indent =' '; if (typeof space ===' nomor ') {for (i = 0; i <spasi ; i+= 1) {indent+= ' ';}} lain jika (typeof space ===' string ') {indent = space;} rep = replacer; if (replacer && typeof replacer! ==' function '&& (typeof replacer! ==' objek '|| typeof Replacer .length! == 'number')) {throw new error ('json.stringify');} return str ('', {'': value});};} if (typeof json.parse! == ' function ') {json.parse = function (text, reviver) {var j; function walk (holder, key) {var k, v, value = holder [key]; if (value && typeOf value === 'objek') {for (k in value) {if (object.hasownproperty.call (value, k) ) {v = walk (value, k); if (v! == tidak terdefinisi) {value [k] = v;} else {hapus nilai [k];}}}} return reviver.call (holder, key, value);} cx.LastIndex = 0; if (cx.test (text)) {text = text.replace (cx, function (a) {return '// u'+(' 0000 '+a.charcodeat (0) .toString (16)). Slice (-4);});} if (/^[/] ,: {}/s]*$/. Test (teks. ganti (/// (?: [//// bfnrt] | u [0-9a-fa-f] {4})/g, '@'). Ganti (/[^/// n/r] *| true | false | null |-?/d+(?: /./ d*)? (?: [ee] [+/-]?/d+)?/g, ']'). Ganti (/( ?:^|: |,) (?:/s*/[)+/g, ''))) {j = eval ('('+text+')'); return typeOf reviver === 'function'? walk ({'': j}, ''): j;} lempar sintakser baru ('json.parse');};}} ()); </skrip>