<%@ WebService Language="C#" Class="VendorsDataService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using Microsoft.Web.Preview.Services;
using System.Collections;
using System.Collections.Generic;

public class Vendor
{
  string _AccountNumber;
  string _Name;

  public string AccountNumber
  {
    get
    {
      return _AccountNumber;
    }
    set
    {
      _AccountNumber = value;
    }
  }

  public string Name
  {
    get
    {
      return _Name;
    }
    set
    {
      _Name = value;
    }
  }

  public Vendor(string AccountNumber, string Name)
  {
    this._AccountNumber = AccountNumber;
    this._Name = Name;
  }

  public Vendor()
  {
  }
}

[WebService(Namespace = "http://hauser-wenz.de/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class VendorsDataService : DataService
{

  [DataObjectMethod(DataObjectMethodType.Select)]
  public Vendor[] GetVendors()
  {
    SqlConnection conn = new SqlConnection(
      "server=(local)\\SQLEXPRESS; Integrated Security=true; Initial Catalog=AdventureWorks");
    conn.Open();
    SqlCommand comm = new SqlCommand(
      "SELECT TOP 10 AccountNumber, Name FROM Purchasing.Vendor",
      conn);
    SqlDataReader dr = comm.ExecuteReader();
    List<Vendor> v = new List<Vendor>();

    while (dr.Read())
    {
      v.Add(new Vendor(
        dr["AccountNumber"].ToString(),
        dr["Name"].ToString()));
    }
    return v.ToArray();
  }
}
