【发布时间】:2011-12-05 20:46:27
【问题描述】:
好的,我在这里有点麻烦。
当我尝试从属于 myproject.account.members 命名空间
的页面调用网络服务时到属于 myproject.services 的 Web 服务时出现错误
///-----修改:添加错误信息-----///
---------------------------
Message from webpage
---------------------------
responseText=
textStatus=error
errorThrown=Unknown
---------------------------
OK
---------------------------
例如。
来自 somepage.aspx 的 jquery ajax 调用属于 myproject.account.members
$.ajax({
type: "POST",
url: '<%=ResolveUrl("~/Services/productService.asmx/getSomething") %>',
data: '',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result){
alert(result.d)
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert("responseText=" + XMLHttpRequest.responseText + "\ntextStatus=" + textStatus + "\nerrorThrown=" + errorThrown);
}
});
webservice 代码属于 myproject.Services
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace myproject.Services
{
/// <summary>
/// Summary description for productService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class productService : System.Web.Services.WebService
{
[WebMethod]
public String getSomething()
{
return "Hello World";
}
}
}
基本上,如果我将 web 服务的命名空间从 myproject.Services 更改为 myproject.account.member,如果我从属于 myproject.account 的页面调用它,它就会起作用.members 命名空间...但如果将命名空间设置为 myproject.Services 将不起作用
请帮助..我该如何解决这个问题?如果我想在我的项目中从多个不同的命名空间调用相同的服务怎么办?`在此处输入代码
【问题讨论】:
-
“我得到一个错误”没有给我们足够的细节。请告诉我们实际发生的情况。
标签: jquery .net ajax web-services namespaces