<%@ Webservice Language="C#" class="test" %>
using System;
using System.Data;
using System.Web.Services;
using System.Data.OleDb;
public class test:WebService
{
[WebMethod]
public DataSet getds()
{
DataSet ds=new DataSet();
OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:/service.mdb");
OleDbDataAdapter da=new OleDbDataAdapter("select top 3 id,name,content from example",conn);
conn.Open();
da.Fill(ds,"example");
conn.Close();
return ds;
}
}
调试的时候,调用getds方法,可以得到如下XML文件:
<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns="
http://tempuri.org/">
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="zh-CN">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="example">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:int" minOccurs="0" />
<xs:element name="name" type="xs:string" minOccurs="0" />
<xs:element name="content" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<example diffgr:id="example1" msdata:rowOrder="0">
<id>1</id>
<name>lau</name>
<content>hello</content>
</example>
<example diffgr:id="example2" msdata:rowOrder="1">
<id>2</id>
<name>xiao</name>
<content>it's good</content>
</example>
<example diffgr:id="example3" msdata:rowOrder="2">
<id>3</id>
<name>bb</name>
<content>wa~</content>
</example>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
返回的这个DataSet是[object Object]类型,根据wsdl得到的results的数据类型是.net DataSet,不过在flash固有的数据类型里并不包括这项。