Javascript 从 HTML 页面调用和显示 REST 或 SOAP 响应
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7981841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Call and Display REST or SOAP response from a HTML page
提问by Doomsknight
I am trying to call the webservice to get a simple list of tasks, from a windows 7 gadget.
我正在尝试调用 Web 服务以从 Windows 7 小工具获取简单的任务列表。
Now, basically its a html page, with Javascript if need be. Ive looked at Simplest SOAP example, but had no luck. (My button doesnt do anything)
现在,基本上它是一个 html 页面,如果需要,可以使用 Javascript。我看过Simplest SOAP example,但没有运气。(我的按钮不做任何事情)
There is a button on my html page. The procedure would be.
我的 html 页面上有一个按钮。程序将是。
Click the button.
Sends request to web service.
Recieve response from webservice
display the response below the button.
单击按钮。
向 Web 服务发送请求。
接收来自网络服务的响应
在按钮下方显示响应。
Any example code, as complete as possible would be much appreciated. Or at worst, some detailed instructions following my 4 steps, and how I achieve it.
任何示例代码,尽可能完整,将不胜感激。或者最糟糕的是,按照我的 4 个步骤以及我如何实现它的一些详细说明。
Ive never fully understood javascript, but think I did it correctly. (Note, it works fine connecting via the URL, to the REST service).
我从来没有完全理解 javascript,但我认为我做对了。(注意,它可以通过 URL 连接到 REST 服务正常工作)。
<html>
<head>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script>
function getTasks() {
$.get("https://localhost/TEST.TestService.svc/rest/Services?CostCentreNo=1&Filter=0",
function(data){
alert("Data Loaded: " + data);
});
}
</script>
</head>
<body>
<button onclick="javascript:getTasks();">Show Match</button>
</body>
</html>
采纳答案by david
did you read this How do i get access to SOAP response property?and the answer, if you get stuck i might abeable to help
您是否阅读了这篇如何访问 SOAP 响应属性?和答案,如果你被卡住了,我可能会帮忙
for REST JavaScript REST client Library
用于 REST JavaScript REST 客户端库