我在我的网络服务中有两个功能,一个用于获取所有记录,另一个用于更新记录。为了实现这一点,我在 Web 服务中使用了数据集(数据表)。
[WebMethod( Description = "Returns Northwind Customers", EnableSession = false )]
public DataSet GetCustomers()
{
SqlDataAdapter custDA = new SqlDataAdapter("SELECT CustomerID, CompanyName FROM Customers", nwindConn);
DataSet custDS = new DataSet();
custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey;
custDA.Fill(custDS, "Customers");
return custDS;
}
[WebMethod( Description = "Updates Northwind Customers", EnableSession = false )]
public DataSet UpdateCustomers(DataSet custDS)
{
SqlDataAdapter custDA = new SqlDataAdapter();
custDA.InsertCommand = new SqlCommand("INSERT INTO Customers (CustomerID, CompanyName) " +
"Values(@CustomerID, @CompanyName)", nwindConn);
custDA.InsertCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID");
custDA.InsertCommand.Parameters.Add("@CompanyName", SqlDbType.NChar, 15, "CompanyName");
custDA.UpdateCommand = new SqlCommand("UPDATE Customers Set CustomerID = @CustomerID, " +
"CompanyName = @CompanyName WHERE CustomerID = @OldCustomerID", nwindConn);
custDA.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID");
custDA.UpdateCommand.Parameters.Add("@CompanyName", SqlDbType.NChar, 15, "CompanyName");
SqlParameter myParm = custDA.UpdateCommand.Parameters.Add("@OldCustomerID", SqlDbType.NChar, 5, "CustomerID");
myParm.SourceVersion = DataRowVersion.Original;
custDA.DeleteCommand = new SqlCommand("DELETE FROM Customers WHERE CustomerID = @CustomerID", nwindConn);
myParm = custDA.DeleteCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID");
myParm.SourceVersion = DataRowVersion.Original;
custDA.Update(custDS, "Customers");
return custDS;
}
我想从任何其他客户端(不是 net framework )调用这个网络服务,比如 fiddler 或 android 或 php 。
你能告诉我如何从提琴手调用这个网络服务来测试它。它是否工作正常?
建议我任何可用的链接或示例代码。