C# 如何在javascript或jquery中调用基于asp.NET3.5SOAPXML的Web服务?
我是jquery新手,试图在jquery中使用asp.NET3.5制作的webservice,但我不知道为什么我不能使用它。 我在网上找到的所有例子都和我现在做的一样,但我不知道代码发生了什么变化 谁能帮帮我吗 这是我的javascript代码C# 如何在javascript或jquery中调用基于asp.NET3.5SOAPXML的Web服务?,c#,javascript,jquery,json,web-services,C#,Javascript,Jquery,Json,Web Services,我是jquery新手,试图在jquery中使用asp.NET3.5制作的webservice,但我不知道为什么我不能使用它。 我在网上找到的所有例子都和我现在做的一样,但我不知道代码发生了什么变化 谁能帮帮我吗 这是我的javascript代码 var soapMessage = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/200
var soapMessage =
'<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/"> \
<soap:Body> \
<test xmlns="http://tempuri.org/"> \
<param>this is a test parameter</param> \
</test> \
</soap:Body> \
</soap:Envelope>';
$.ajax({
url: "http://localhost:50575/Service1.asmx?op=test",
type: "POST",
dataType: "xml",
data: soapMessage,
complete: hi,
error: function (a, b, c) {
alert("error");
},
contentType: "text/xml; charset=\"utf-8\""
});
function hi(xmlHttpRequest, status) {
alert($(xmlHttpRequest.responseText).text());
alert($(xmlHttpRequest.responseXML).find('Mymessage').text());
}
传递给错误处理程序的第一个对象应该包含一些有用的信息。尝试在您正在使用的任何调试工具中“扩展”a。不要只是“提醒”它的价值
具体来说,查找
a.status
和a.responseText
。这会让您对正在发生的事情有一个很好的了解。我建议您试一试,这是一个很好的web调试工具,应该可以帮助您确定问题所在 在错误处理程序中,a、b和c的值是多少?a是[object object]b是“error”,c是emptya。状态是0,a.responseText是EmptyID如何调试javascript?目前,我正在使用警报检查结果。嗯,这很奇怪。您是否尝试将调试器附加到服务器端代码,以查看服务器端是否发生了任何事情?你能发布你的服务器端代码吗?我已经用服务器端代码更新了我的问题,请看一看我在服务器端附加了一个调试程序,但它从未到达调试点,
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public message test(string param)
{
message mymsg = new message();
mymsg.head = "message head";
mymsg.Mymessage = "Test string with param " + param;
return mymsg;
}