使用JS调用WebService接口
<script>
$(document).ready(function () { var username = "admin";
var password = "123456"; /*==JS使用HTTP-POST方式调用WebService接口(仅IE调试)==*/
//var host_url = "http://localhost/Interface/Login.asmx/Login?UserName=" + username + "&Password=" + password ; var url = "http://localhost/Interface/Login.asmx/Login";
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", url, false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send("UserName=" + username + "&Password=" + password); if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
document.getElementById("page").innerHTML = xmlHttp.responseText;
} else {
alert(" not 200! =" + xmlHttp.status);
}
} else {
alert(" not 4! =" + xmlHttp.readyState);
} /*==JS使用SOAP方式调用WebService接口(仅IE调试)==*/
//SOAP1.2请求数据格式(请参照http://localhost/Interface/Login.asmx/Login?op=Login) var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">';
data = data + '<soap12:Body>';
data = data + '<Login xmlns="http://mmp.test.com/DataInterface/">';
data = data + '<UserName>' + username;
data = data + '</UserName>';
data = data + '<Password>' + password;
data = data + '</Password>';
data = data + '</Login>';
data = data + '</soap12:Body>';
data = data + '</soap12:Envelope>'; var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "http://localhost/Interface/Login.asmx", false);
xmlhttp.setRequestHeader("Content-Type", "application/soap+xml");
xmlhttp.send(data);
document.getElementById("page12").innerHTML = xmlhttp.responseText;
});
</script>
使用JS调用WebService接口的更多相关文章
- js调用Webservice接口案例
第一步:新建Webservice接口 主文件方法 using System;using System.Collections.Generic;using System.Web;using System ...
- Java调用webservice接口方法
java调用webservice接口 webservice的 发布一般都是使用WSDL(web service descriptive langu ...
- php中创建和调用webservice接口示例
php中创建和调用webservice接口示例 这篇文章主要介绍了php中创建和调用webservice接口示例,包括webservice基本知识.webservice服务端例子.webservi ...
- 使用soapui调用webservice接口
soapui是专门模拟调用webservice接口的工具,下面介绍下怎么使用: 1.下载soapui并安装: 2.以免费天气获取接口为例:http://www.webservicex.net/glob ...
- JS调用WebService,发布到IIS,网页提示WebService未定义[已解决]
VS2013中,JS调用WebService,一直运行正常.部署到WindowsServer2008之后,在网页中访问,始终提示网页中有错误,点开之后发现是WebService未定义. 于是上网查解决 ...
- Js 调用 WebService 实例
Html页面代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/ ...
- java 调用webservice接口wsdl,推荐使用wsdl2java,放弃wsimport
网上说wsimport是jdk1.6后自带的客户端生成调用webservice接口的工具,其实我挺喜欢原生的东西,毕竟自家的东西用着应该最顺手啊,但往往让人惊艳的是那些集成工具. 本机jdk1.8.1 ...
- asp.net 练习 js 调用webservice
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- SQL调用WebService接口
今天在做一个非常奇葩的东西.中间有个过程要在SQL触发器里面调用webservice接口.呵呵~ ALTER TRIGGER tgr_UpdateMemcached ON dbo.[User] AFT ...
随机推荐
- PostgreSQL中,如何查表属于哪个数据库
db1=# \x Expanded display is on. db1=# SELECT * FROM information_schema.tables WHERE table_name='tab ...
- 安装Loopback网卡/回环网卡
$CurrentPath = $MyInvocation.MyCommand.Path.substring(0,$MyInvocation.MyCommand.Path.LastIndexOf('\' ...
- Gym 100637F F. The Pool for Lucky Ones 暴力
F. The Pool for Lucky Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- HashMap解决hash冲突的方法
HashMap 采用一种所谓的“Hash 算法”来决定每个元素的存储位置.当程序执行 map.put(String,Obect)方法 时,系统将调用String的 hashCode() 方法得到其 h ...
- delphi 滚屏
滚屏 uses MSHTML;var a: IHTMLDocument2; x,y:Integer;begin y:=y+20; //加减进行上下滚动 a :=WebB ...
- [AngularJS] Consistency between ui-router states and Angular directives
ui-router's states and AngularJS directives have much in common. Let's explores the similarities bet ...
- ios开发——实用技术篇OC篇&获取设备唯一标识
获取设备唯一标识 WWDC 2013已经闭幕,IOS7 Beta随即发布,界面之难看无以言表...,简直就是山寨Android. 更让IOS程序猿悲催的是,设备唯一标识的MAC Address在IOS ...
- C链表操作
#define _CRT_SECURE_NO_WARNINGS #include <stdlib.h> #include <string.h> #include <std ...
- google maps api申请的问题
现在已经改由统一的GOOGLE API控制台进行所有GOOGLE API的管理了. 方法是使用Google帐号登入 https://code.google.com/apis/console. 然后在所 ...
- Session fixation--wiki
http://en.wikipedia.org/wiki/Session_fixation In computer network security, session fixation attacks ...