/* This method is called by ajax to call the Java Axis web service. The call example is as follows: callaxiswspost ("remote method name", new array ("parameter name 1 ", "parameter name 2 "...), new array (parameter value 1, parameter value 2 ...), "WSDL address", "namespace", function (result) {// callback processing after Ajax is completed, result is the result returned by the server}, function () {// handle Ajax loading, such as the loading mask layer and the submitted button disabled}); */function callaxiswspost (method, variable, value, URL, _ namespace, callback, loadprocess) {function getlen (STR) {var bytescount = 0; For (VAR I = 0; I <Str. len Callback; I ++) {var c = Str. charat (I); If (/^ [\ u0000-\ u00ff] $ /. test (c) // match the double byte {bytescount + = 1;} else {bytescount + = 2;} return bytescount;} var XMLHTTP = NULL; If (window. activexobject) {XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");} else if (window. XMLHttpRequest) {XMLHTTP = new XMLHttpRequest ();} var data; data = '<? XML version = "1.0" encoding = "UTF-8"?> '; Data = Data +' <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/"> '; data = Data + '<soap: Body>'; Data = Data + '<' + method + 'xmlns = "'+ _ namespace +'"> '; for (VAR I = 0; I <variable. length; I ++) {DATA = Data + '<' + variable [I] + '>' + value [I] + '</' + variable [I] + '> ';} data = Data + '</' + method + '>'; Data = Data + '</soap: Body>'; Data = Data + '</soap: envelope> '; XMLHTTP. onreadystatechange = function () {If (XMLHTTP. readystate = 1) {If (loadprocess) loadprocess () ;}if (XMLHTTP. readystate = 4) {If (XMLHTTP. status = 200) {If (callback) callback (XMLHTTP. responsetext) ;}} XMLHTTP. open ("Post", URL, true); XMLHTTP. setRequestHeader ("Content-Type", "text/XML; charset = UTF-8"); XMLHTTP. setRequestHeader ("Content-Length", getlen (data); XMLHTTP. setRequestHeader ("soapaction", _ namespace + method); XMLHTTP. send (data );}
Call example
Callaxiswspost ("getpolebylineid", new array ("lineid"), new array (record. Data. translinid), "http: // 192.168.1.129: 8005/axis2/services/simpleservice? WSDL "," http://ws.apache.org/axis2 ", function (result) {var xmldoc = getxmldom (result); var returns = xmldoc. getelementsbytagname ("return"); var polestr = Returns [0]. childnodes [0]. nodevalue; var poleinfoarray = polestr. split (";"); For (VAR I = 0; I <poleinfoarray. length-1; I ++) {var poleinfos = poleinfoarray [I]. split (","); var id = poleinfoarray [I]; var name = poleinfos [0]; transstartarray [I] = [ID, name]; transendarray [I] = [ID, name];} combotowerstart. clearvalue (); combotowerstart. store. removeall (); combotowerend. clearvalue (); combotowerend. store. removeall (); combotowerstart. store. loaddata (transstartarray); var towerstartid = combotowerstart. store. getat (0 ). get ('towerstartid'); // The first combotowerstart is selected by default. setvalue (towerstartid); combotowerend. store. loaddata (transendarray); var towerendid = combotowerend. store. getat (0 ). get ('towerendid'); // The first combotowerend is selected by default. setvalue (towerendid); EFS. getext ('btnlinesflightok '). enable () ;}, function () {EFS. getext ('btnlinesflightok '). disable ();});