1
我在我的Web服務中創建了兩個函數,一個用於獲取所有記錄,另一個用於更新記錄。爲了達到這個目的,我在web服務中使用了數據集(datatable)。如何從提琴手傳遞數據到webservice?
[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;
}
我想從任何其他客戶端(而不是網絡框架)調用此Web服務,如fiddler或android或php。
你可以告訴我怎麼稱呼這個來自提琴手的網絡服務來測試它。無論工作是否正常?
向我推薦任何可用的鏈接或示例代碼。