This documentation is archived and is not being maintained.

How to: Group Related Information into a Single Web Service Method

Visual Studio 2010

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation .

The following code example demonstrates how to group related information into a single Web service method. This example illustrates one of the guidelines explained in the topic, Design Guidelines for XML Web Services Created Using ASP.NET.


<%@ WebService Language="C#" Class="DataService" %>
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
public class DataService {
   public DataSet GetTitleAuthors() {
        SqlConnection myConnection = new SqlConnection("Persist Security Info=False;Integrated Security=SSPI;server=localhost;database=pubs");
        SqlDataAdapter myCommand1 = new SqlDataAdapter ("select * from Authors", myConnection);
        SqlDataAdapter myCommand2 = new SqlDataAdapter("select * from Titles", myConnection);
        DataSet ds = new DataSet();
        myCommand1.Fill(ds, "Authors");
        myCommand2.Fill(ds, "Titles");
        return ds;

See Also