如何调用远程Web服务 [英] How do I call remote webservice
问题描述
嗨 -
我获得了一个创建的公共Web服务的链接。我试图通过一个参数来调用这个服务,但我对服务并不是那么好,还在学习它们。
webmethod需要一个部件号,我不确定如何传递它以便返回数据。
这是我的ajax电话
Hi -
I was given a link to a public web service that was created. I'm trying to call this service passing a parameter but I'm not that good with services and still learning them.
The webmethod requires a part number and I'm not sure really how to pass that in order to return data.
Here is my ajax call
var partNumber = 27882;
$.ajax({
type: "POST",
url: "http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts" + "?" + partNumber,
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function (data) {
alert(data.d)
},
error: function () {
console.log("obviously didnt work");
}
});
再次感谢任何帮助学习这些文章的文章将不胜感激。我正在运行的很多东西都是非常具体的,我只是想要全面理解。
Thanks additionally any articles to help with learning these would be greatly appreciated. Lot of the things I'm running across are very specific and i'm just trying to get a good overall understanding.
推荐答案
.ajax({
键入:POST,
url:http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts+?+ partNumber,
contentType:application / json; charset = utf-8,
dataType:jsonp,
成功:函数(数据){
alert(data.d)
},
错误:函数(){
console.log(显然没有用);
}
});
.ajax({ type: "POST", url: "http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts" + "?" + partNumber, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function (data) { alert(data.d) }, error: function () { console.log("obviously didnt work"); } });
再次感谢任何帮助学习这些文章的文章将不胜感激。我正在运行的很多东西都是非常具体的,我只是想要获得一个很好的整体理解。
Thanks additionally any articles to help with learning these would be greatly appreciated. Lot of the things I'm running across are very specific and i'm just trying to get a good overall understanding.
这取决于服务期望,你需要询问谁提供它。如果它想要它在URL上那么它将是类似
类型:GET,
url:http:// xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts?partNumber =+ partNumber,
但你必须问他们参数的名称是什么他们期待的是。如果要发布那么它就像是
类型:POST,
url:http:// xxxxxx .xxxxx.com / xxxx / Service.asmx / GetParts,
数据:{partNumber:+ partNumber +},
最终你必须查阅该服务的文档,谷歌如何从jQuery调用web服务以获取相关示例。
It depends on the service expects, you'll need to ask whoever provides it. If it wants it on the URL then it will be something like
type: "GET",
url: "http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts?partNumber = " + partNumber,
but you'll have to ask them what the name of the parameter they are expecting is. If it is to be posted then it'll be like
type: "POST",
url: "http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts",
data: "{partNumber:" + partNumber + "}",
ultimately you'll have to consult the documentation for the service and google how you call web services from jQuery for relevant examples.
这篇关于如何调用远程Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!