Javascript calls WebService Based on soap Communication

Source: Internet
Author: User

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>

</Head>
<Script language = "JavaScript" src = "jquery. js"> </SCRIPT>
<Script language = "JavaScript">
Function checkqqonline (){
VaR QQ = Document. getelementbyid ("QQ"). value;
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 + '<qqcheckonline xmlns = "http://WebXml.com.cn/"> ';
Data = Data + '<qqcode>' + QQ + '</qqcode> ';
Data = Data + '</qqcheckonline> ';
Data = Data + '</soap: Body> ';
Data = Data + '</soap: envelope> ';
VaR url = "http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx ";
VaR XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
XMLHTTP. Open ("Post", URL, false );
XMLHTTP. setRequestHeader ("Content-Type", "text/XML; charset = UTF-8 ");
XMLHTTP. setRequestHeader ("Content-Length", Data. Length );
XMLHTTP. setRequestHeader ("host", "webservice.webxml.com.cn ");
XMLHTTP. setRequestHeader ("soapaction", "http://WebXml.com.cn/qqCheckOnline ");
XMLHTTP. Send (data );
VaR x = XMLHTTP. responsexml;
VaR temp = x. childnodes [1]. text;
VaR MSG = "";
If (temp = "Y "){
MSG = "online ";
} Else if (temp = "N "){
MSG = "offline or invisible! ";
} Else if (temp = "e "){
Alert ("Incorrect QQ number ");
}
Alert ("query QQ number:" + QQ + "Current status:" + MSG );
}
 
 
 
Function checkmobile (){
VaR mobile = Document. getelementbyid ("mobile"). value;
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 + '<getmobilecodeinfo xmlns = "http://WebXml.com.cn/"> ';
Data = Data + '<mobilecode>' + mobile + '</mobilecode> ';
Data = Data + '<userid>' + "" + '</userid> ';
Data = Data + '</getmobilecodeinfo> ';
Data = Data + '</soap: Body> ';
Data = Data + '</soap: envelope> ';
VaR url = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx? OP = getmobilecodeinfo ";
VaR XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
XMLHTTP. Open ("Post", URL, false );
XMLHTTP. setRequestHeader ("Content-Type", "text/XML; charset = UTF-8 ");
XMLHTTP. setRequestHeader ("Content-Length", Data. Length );
XMLHTTP. setRequestHeader ("host", "webservice.webxml.com.cn ");
XMLHTTP. setRequestHeader ("soapaction", "http://WebXml.com.cn/getMobileCodeInfo ");
XMLHTTP. Send (data );
VaR x = XMLHTTP. responsexml;
VaR temp = x. childnodes [1]. text;
Alert (temp );
}

 

Function qqonline (qq ){
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 + '<qqcheckonline xmlns = "http://WebXml.com.cn/"> ';
Data = Data + '<qqcode>' + QQ + '</qqcode> ';
Data = Data + '</qqcheckonline> ';
Data = Data + '</soap: Body> ';
Data = Data + '</soap: envelope> ';
VaR url = "http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx ";
VaR XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
XMLHTTP. Open ("Post", URL, false );
XMLHTTP. setRequestHeader ("Content-Type", "text/XML; charset = UTF-8 ");
XMLHTTP. setRequestHeader ("Content-Length", Data. Length );
XMLHTTP. setRequestHeader ("host", "webservice.webxml.com.cn ");
XMLHTTP. setRequestHeader ("soapaction", "http://WebXml.com.cn/qqCheckOnline ");
XMLHTTP. Send (data );
VaR x = XMLHTTP. responsexml;
VaR temp = x. childnodes [1]. text;
VaR MSG = "";
If (temp = "Y "){
MSG = "online ";
} Else if (temp = "N "){
MSG = "offline or invisible! ";
} Else if (temp = "e "){
Alert ("Incorrect QQ number ");
}
Return QQ + MSG;
}
</SCRIPT>
<Script language = "JavaScript">
$ (Document). Ready (function (){
Document. getelementbyid ("lab1"). innertext = qqonline (715733768 );
Document. getelementbyid ("lab2"). innertext = qqonline (511021266 );
});
</SCRIPT>
<Body>
QQ number: <input type = "text" name = "QQ" id = "QQ"/> <input type = "button" name = "Search" value = "query" onclick = "checkqqonline () "/> <br/>
Mobile phone number: <input type = "text" name = "mobile" id = "mobile"/> <input type = "button" name = "Search" value = "query" onclick = "checkmobile () "/> <br/>
<Label id = "lab1"> </label> <br/>
<Label id = "lab2"> </label>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.