[分享]VFP调用ASP.NET Web服务中的DataSet
一、ASP.NET Web Service代码
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
namespace WebService1
{
/// <summary>
/// Service1 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public DataTable GetProducts(int CategoryID)
{
SqlConnection sqlconn = new SqlConnection("server=.;uid=sa;database=NorthWind");
sqlconn.Open();
SqlDataAdapter sda = new SqlDataAdapter("select * from Products where CategoryID=" + CategoryID, sqlconn);
DataSet ds = new DataSet();
sda.Fill(ds,"temp");
sqlconn.Close();
return ds.Tables["temp"];
}
}
}
二、测试WEB服务可用后VFP怎么将其转换成临时表
* 调用Web服务部分
oSOAP=Createobject("MSSOAP.soapclient30")
oSOAP.MSSoapInit("http://localhost:1442/Service1.asmx?wsdl")
cXML=oSOAP.GetProducts(1) && xml对象
* 将xml转换成临时表
oXMLAdapter=Createobject("XMLAdapter")
oxmladapter.LoadXML(cXML.context.XML) && xml的内容,这里一直不知道怎么调用,今天终于找到了。
oXMLAdapter.Tables(1).Alias="curCustomer"
oXMLAdapter.Tables(1).ToCursor()
Browse && 呵呵可以看到了吧! By feiyafei2008 qq:459838553