【发布时间】:2010-12-16 18:27:21
【问题描述】:
我在 asp.net 4.0 中编写了一个 web 服务,它返回一个强类型数据表,如下所示。 数据表是使用 Visual Studio 设计器创建的。
[WebService(Namespace = "http://tempuri.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class ConsumerService : System.Web.Services.WebService
{
[WebMethod]
public ConsumerTable GetConsumer(string key)
{
...
}
}
我有一个 asp.net 1.1 应用程序,我想在其中使用 webmethod 返回的 ConsumerTable。我在 asp.net 1.1 应用程序中添加服务 Web 引用,并在我想要使用信息的 aspx 页面中创建代理实例。我不调用 web 方法...只是创建代理实例,如下所示,
public class Test : System.Web.UI.Page
{
svc.ConsumerService svc = new testProj.svc.ConsumerService();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
}
一切编译正常。但是当我尝试执行代码时,出现以下错误。
名为 '' 的 XML 元素来自 命名空间“http://tempuri.org”是 已经存在于当前范围内。 使用 XML 属性指定另一个 元素的 XML 名称或命名空间。
我尝试在 4.0 Web 应用程序中使用 webmethod,一切正常。谁能帮我解决这个错误?在 1.1 应用程序中使用 4.0 类型的数据表/数据集是否有更好的方法?
【问题讨论】: