Je suis en contact avec WebService depuis longtemps, mais il n'y a pas beaucoup de tutoriels à utiliser ASP à appeler, et il n'est pas courant de convertir en JSON.
Définissez d'abord les données SOAP, puis créez l'objet HTTP, puis soumettez-le à l'aide du post, et obtenez le code d'état de 200, ce qui signifie que l'appel est réussi, puis passez à l'opération suivante ...
Jetez un œil au code d'implémentation spécifique
<! - # include virtual = / include / json.min.asp -> <% dim strXmldim str'definition Soap message strxml = <? Xml version = '1.0' Encoding = 'utf-8'?> StrXml = strXml & <SOAP: Envelope xmlns: xsi = 'http: //www.w3.org/2001/xmlschema-instance' xmlns: xsd = 'http: //www.w3.org/2001/xmlschema' xmlns: soap = ' http://schemas.xmlsoap.org/soap/envelope/ '> strXml = strXml & <SOAP: Body> strXml = strXml & <getCategories xmlns = 'http: //tempuri.org/'> strXml = strxml & <reqcode> 30000001 </sssSSS> 'Paramètre 1strxml = strXml & <gign> sssss </ign> 'Paramètre 2Strxml = strXml & </ getCategories> strXml = strXml & </ soap: body> strXml = strxml & </apap: enveloppe> set h = createObject (Microsoft.xmlhttp)' POSTE, http://www.domain.com/webservice.asmx, falseh.setRequestHeader Content-Type, Text / Xml; .org / getCategoriessh.send (strXml) 'Afficher les informations XML renvoyées si H.STATUS = 200 alors définissez xmldoc = server.createObject (msxml.domDocument) JSONText = xmldoc.childNodes (1) .Text 'Convertid to JSON, appelez JSON.min.asp set catégories = json.parse (jsontex i) .CategoryName)) 'Property for j = 0 to categories.get (i) .Labels.length - 1' Collection Response.Write (CSTR (catégories.get (i) .Labels.get (j) .LabelName))) Next Suivant <pren name = CODE CLASS = VB> <Script Language = JavaScript runat = server> if (! array.prototype.get) {array.prototype.get = function (prop) {return this [prop];}} utilise 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.getUtCulyear () + '-' + f (this.getUtcMonth () + 1) + '-' + f (this.getUtcDate ()) + 't' + f (this. .getutchours ()) + ':' + f (this.getUtcMinUtes ()) + ':' + f (this.getUtcSeconds ()) + 'z': null;}; string.prototype.tojson = nombre.prototype. tojson = boolean.prototype.tojson = fonction (key) {return this.valueof ();};} var cx = / [/? /? /? - /? /? /? /? /? /? - /? /? - /? /? - /? /? - /? /? - /? /? - /?] / g, échappé = / [/ /// 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 Escapable.Test (String)? '' + String.replace (Échapable, fonction (a) {var c = meta [a]; return typeof c === 'String'? C: '// u' + ('0000 '+ a.CharCodeat (0) .toString (16)). Slice (-4);}) +' ':' '+ String +' ';} fonction str (key, holder) {var i, k, v, longueur, esprit = gap, partiel, value = holder [key]; if (valeur && typeof value === 'objet' && typeof value.tojson === 'function') {value = value.tojson (key);} if (typeof rep === 'function') {value = rep.call (holder, key, value);} switch (typeof valeur) {cas'string ': return quote (valeur); cas'number': return isFinite (value)? String (value): 'null'; cas'boolean ': cas'null': return String (valeur); cas'object ': if (! Value) {return'null';} gap + = indent; partial = []; if (object.prototype.tostring.apply (valeur) === '[objet Array] ') {longueur = valeur.length; for (i = 0; i <longueur; i + = 1) {partial [i] = str (i, valeur) ||' null ';} v = partial.length = = Vag ',') + ']'; GAP = Mind; return v;} if (rep && type de rep === 'objet') {longueur = rep.length; for (i = 0; i <longueur; i + = 1) { k = rep [i]; if (typeof k === 'string') {v = str (k, valeur); if (v) {partial.push (quote (k) + (gap? ':': ':') + v);}}} } else {for (k en valeur) {if (object.hasownproperty.call (value, k)) {v = str (k, valeur); if (v) {partial.push (quote (k) + (GAP? ': ':': ') + v);}}}}} v = partial.length === 0?' {} ': GAP?' {/ n '+ gap + partial.join (', / n '+ GAP) + '/ n' + Mind + '}': '{' + partial.join (',') + '}'; gap = ment; return v;}} if (typeof json.stringify! == 'function ') {Json.stringify = function (valeur, remplaceur, espace) {var i; gap =' '; indent =' '; if (typeof espace ===' nombre ') {for (i = 0; i <espace ; ';}} else if (typeof Space ===' String ') {indent = space;} rep = remplacer; if (remplaceur && type de remplaceur! ==' function '&& (type de remplacement! ==' objet '|| Typeof remplaceur .length! == 'nombre')) {throw new error ('json.stringify');} return str ('', {'': value});};} if (typeof json.parse! == ' function ') {json.parse = fonction (text, reviver) {var j; fonction walk (holder, key) {var k, v, value = holder [key]; if (valeur && typeof value === 'object') {for (k in value) {if (object.hasownproperty.call (value, k) ) ot reviver.call (holder, key, valeur);} cx.lastIndex = 0; if (cx.test (text)) {text = text.replace (cx, fonction (a) {return '// u' + (' 0000 '+ A.CharCodeat (0) .ToString (16)). Slice (-4);});} if (/ ^ [/] ,: {} / s] * $ /. Test (texte. remplacer (/// (?: [//// bfnrt] | u [0-9a-fa-f] {4}) / g, '@'). Remplace (/ [^ /// n / r] * | true | false | null | -? / d + (?: /./ d *)? (?: [ee] [+/-]? / d +)? / g, ']'). ?: ^ |: |,) (?: / s * / [) + / g, ''))) {j = eval ('(' + text + ')'); return typeof reviver === 'function'? walk ({'': j}, ''): j;} lance new syntaxerror ('json.parse');};}} ()); </ script> set xmlDoc = NothingElse Response.Write H.Status & Response.Write H.Statustextend If%> Pièce jointe: json.min.asp <Script Language = JavaScript runat = server> if (! array.prototype.get) {array.prototype.get = function (prop) {return this [prop];}} utilise strict; if (! this.json) {json = {};} (fonction () {fonction f (n) {return n <10? '0' + n: n;} if (typeof date.prototype.tojson! == 'function') {date.prototype. tojson = fonction (key) {return isfinite (this.valueof ())? this.getUtCulyear () + '-' + f (this.getUtcMonth () + 1) + '-' + f (this.getUtcDate ()) + 't' + f (this. .getutchours ()) + ':' + f (this.getUtcMinUtes ()) + ':' + f (this.getUtcSeconds ()) + 'z': null;}; string.prototype.tojson = nombre.prototype. tojson = boolean.prototype.tojson = fonction (key) {return this.valueof ();};} var cx = / [/? /? /? - /? /? /? /? /? /? - /? /? - /? /? - /? /? - /? /? - /? /? - /?] / g, échappé = / [/ /// 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 Escapable.Test (String)? '' + String.replace (Échapable, fonction (a) {var c = meta [a]; return typeof c === 'String'? C: '// u' + ('0000 '+ a.CharCodeat (0) .toString (16)). Slice (-4);}) +' ':' '+ String +' ';} fonction str (key, holder) {var i, k, v, longueur, esprit = gap, partiel, value = holder [key]; if (valeur && typeof value === 'objet' && typeof value.tojson === 'function') {value = value.tojson (key);} if (typeof rep === 'function') {value = rep.call (holder, key, value);} switch (typeof valeur) {cas'string ': return quote (valeur); cas'number': return isFinite (value)? String (value): 'null'; cas'boolean ': cas'null': return String (valeur); cas'object ': if (! Value) {return'null';} gap + = indent; partial = []; if (object.prototype.tostring.apply (valeur) === '[objet Array] ') {longueur = valeur.length; for (i = 0; i <longueur; i + = 1) {partial [i] = str (i, valeur) ||' null ';} v = partial.length = = Vag ',') + ']'; GAP = Mind; return v;} if (rep && type de rep === 'objet') {longueur = rep.length; for (i = 0; i <longueur; i + = 1) { k = rep [i]; if (typeof k === 'string') {v = str (k, valeur); if (v) {partial.push (quote (k) + (gap? ':': ':') + v);}}} } else {for (k en valeur) {if (object.hasownproperty.call (value, k)) {v = str (k, valeur); if (v) {partial.push (quote (k) + (GAP? ': ':': ') + v);}}}}} v = partial.length === 0?' {} ': GAP?' {/ n '+ gap + partial.join (', / n '+ GAP) + '/ n' + Mind + '}': '{' + partial.join (',') + '}'; gap = ment; return v;}} if (typeof json.stringify! == 'function ') {Json.stringify = function (valeur, remplaceur, espace) {var i; gap =' '; indent =' '; if (typeof espace ===' nombre ') {for (i = 0; i <espace ; ';}} else if (typeof Space ===' String ') {indent = space;} rep = remplacer; if (remplaceur && type de remplaceur! ==' function '&& (type de remplacement! ==' objet '|| Typeof remplaceur .length! == 'nombre')) {throw new error ('json.stringify');} return str ('', {'': value});};} if (typeof json.parse! == ' function ') {json.parse = fonction (text, reviver) {var j; fonction walk (holder, key) {var k, v, value = holder [key]; if (valeur && typeof value === 'object') {for (k in value) {if (object.hasownproperty.call (value, k) ) ot reviver.call (holder, key, valeur);} cx.lastIndex = 0; if (cx.test (text)) {text = text.replace (cx, fonction (a) {return '// u' + (' 0000 '+ A.CharCodeat (0) .ToString (16)). Slice (-4);});} if (/ ^ [/] ,: {} / s] * $ /. Test (texte. remplacer (/// (?: [//// bfnrt] | u [0-9a-fa-f] {4}) / g, '@'). Remplace (/ [^ /// n / r] * | true | false | null | -? / d + (?: /./ d *)? (?: [ee] [+/-]? / d +)? / g, ']'). ?: ^ |: |,) (?: / s * / [) + / g, ''))) {j = eval ('(' + text + ')'); return typeof reviver === 'function'? walk ({'': j}, ''): j;} lance new syntaxerror ('json.parse');};}} ()); </ script>