如何在不同的项目中调用Web服务 [英] How to call Web service in the different projects

查看:57
本文介绍了如何在不同的项目中调用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中创建了Web服务,并尝试在同一台计算机上的另一个项目中调用该Web服务。使用$ .ajax我调用了该服务



函数CallService(){



$ .ajax({

类型:GET,

url:../ startervice.asmx / Hello World,

数据:'{}',

contentType:application / json; charset = utf-8,

dataType:json,

成功:OnSuccessCall,

错误:OnErrorCall

});

}

函数OnSuccessCall(响应){

$(#Responseserv)。text(response.d);

}

函数OnErrorCall(响应){

$( #Responseserv)。text(response.status ++ response.status.text);

}

给出错误500 ..

当我在Html项目中创建Web服务然后能够调用它。

但我想知道我怎么能在项目外调用Web服务..

I have created web service in one project and trying to call that web service in the other project on the same computer. Using $.ajax i called that service

function CallService() {

$.ajax({
type: "GET",
url: "../startservice.asmx/HelloWorld",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccessCall,
error: OnErrorCall
});
}
function OnSuccessCall(response) {
$("#Responseserv").text(response.d);
}
function OnErrorCall(response) {
$("#Responseserv").text(response.status + " " + response.status.text);
}
giving error 500..
When i create the web service inside the Html project then able to call it.
but i want to know how i can call web service out side the project..

推荐答案

.ajax我称之为服务


函数CallService (){


.ajax i called that service

function CallService() {


.ajax({

type:GET,

url:../ startervice.asmx / HelloWorld,

data:'{}',

contentType:application / json; charset = utf-8,

dataType:json,

成功:OnSuccessCall,

错误:OnErrorCall

});

}

函数OnSuccessCall(响应){
.ajax({
type: "GET",
url: "../startservice.asmx/HelloWorld",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccessCall,
error: OnErrorCall
});
}
function OnSuccessCall(response) {


(#Responseserv)。 text(response.d);

}

函数OnErrorCall(响应){
("#Responseserv").text(response.d);
}
function OnErrorCall(response) {


这篇关于如何在不同的项目中调用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆