随便写了一个
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Xml.Serialization;/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService { public WebService () { //Uncomment the following line if using designed components
//InitializeComponent();
} [WebMethod]
public string[] TEST_WEB_SERVICE()
{
string[] Result = new string[2];
Result[0] = "Hello";
Result[1] = "World";
return Result;
}
[WebMethod]
//[XmlInclude(typeof(List<string>))]
public List<string> Test_Hello_World()
{
List<string> Result = new List<string>();
Result.Add("Hello");
Result.Add("World");
return Result;
}
[WebMethod]
public DataTable TEST_GET_RESULT()
{
DataTable Result = new DataTable();
Result.Columns.Add("Hello", typeof(string));
Result.Columns.Add("World", typeof(string));
DataRow dr = Result.NewRow();
dr[0] = "Hello";
dr[1] = "World";
Result.Rows.Add(dr);
return Result;
}
}
调试该WebService时提示System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set.
at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean writeHierarchy)
at System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter writer)
at System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable serializable, String name, String ns, Boolean isNullable, Boolean wrapped)...........................
我看的一些书上的例子也是这样的,请问各位是什么原因???
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Xml.Serialization;/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService { public WebService () { //Uncomment the following line if using designed components
//InitializeComponent();
} [WebMethod]
public string[] TEST_WEB_SERVICE()
{
string[] Result = new string[2];
Result[0] = "Hello";
Result[1] = "World";
return Result;
}
[WebMethod]
//[XmlInclude(typeof(List<string>))]
public List<string> Test_Hello_World()
{
List<string> Result = new List<string>();
Result.Add("Hello");
Result.Add("World");
return Result;
}
[WebMethod]
public DataTable TEST_GET_RESULT()
{
DataTable Result = new DataTable();
Result.Columns.Add("Hello", typeof(string));
Result.Columns.Add("World", typeof(string));
DataRow dr = Result.NewRow();
dr[0] = "Hello";
dr[1] = "World";
Result.Rows.Add(dr);
return Result;
}
}
调试该WebService时提示System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set.
at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean writeHierarchy)
at System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter writer)
at System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable serializable, String name, String ns, Boolean isNullable, Boolean wrapped)...........................
我看的一些书上的例子也是这样的,请问各位是什么原因???
解决方案 »
- js中如何获取前一个页面的url???
- 很菜鸟的问题:做好的[ASP.NET]项目如何移植到客户机上?
- 在.net源里面用if else 选择输出内容 <%%>中怎么插入<%#DataBinder()%>
- AspNetPager使用问题???
- SqlDataSource1.SelectCommand = "select * from address where code=@a"; 如何添加这个参数
- Web页面数据导出EXcel的问题?
- 上传MP3的时候怎么获取mp3的播放时间长度?
- 准备做一个数据分析软件,想了三种候选实现方案,请大家品评
- asp.net论坛
- flash后台控制轮换广告条的问题
- 请教一个问题,swfupload可以限制单个上传文件的大小吗
- ASP.NET MVC分页控件MvcPager 1.4版发布
呵呵。
数据服务都广泛化了。