you simply need to create "web service" type project in visual studio. it
will generate all the necessary behind the scenes stuff to generate the soap
messages. you just and in your code as if it was a regular method.
Since Visual Studio cannot read my mind, how can I have it generate my
SOAP response in the correct format?
> you simply need to create "web service" type project in visual studio. it
> will generate all the necessary behind the scenes stuff to generate the soap
[quoted text clipped - 20 lines]
> > Thanks,
> > LW
John Saunders - 24 Oct 2006 22:57 GMT
The answer to "how do I get from the DataSet to the response" is, "however
you want to".
The best way will not only depend on some abstract "best practices", but
also on you and your areas of expertise. For instance, if you're good with
XSL, you might want to use a stylesheet to transform the XML of the DataSet
into the correct form for the response. If not, you may simply be better off
copying the data from the DataSet into the proxy objects for the response:
// Proxy classes:
public class Employee
{
public string FirstName ...;
public string LastName ...;
public int ID ...;
}
public class Response
{
public int NumberOfEmployees;
public Employee[] Employees;
}
[WebService]
public class MyService : WebService
{
[WebMethod]
public Response MyMethod(Request request)
{
DataSet ds = GetDataSet(request);
DataTable employeesTable = ds.Tables["Employees"];
Response response = new Response();
response.NumberOfEmployees = employeesTable.Rows.Count;
response.Employees = new Employee[response.NumberOfEmployees];
for (int i=0; i<employeesTable.Rows.Count; i++)
{
DataRow dr = employeesTable.Rows[i];
Employee employee = new Employee();
employee.FirstName = (string) dr["FirstName"];
employee.LastName = (string) dr["LastName"];
employee.ID = (int) dr["ID"];
response.Employees[i] = employee;
}
return response;
}
}
Of course, if your requirements are not this simple, then your solution will
not be this simple, either.
John
LW - 25 Oct 2006 06:55 GMT
John,
Thank you for your response and your code example. It is exactly what I was
looking for. I have been reading about other options that were too
complicated for
me right now, and I was going around in circles.
Appreciate your help!
Cheers,
LW
> The answer to "how do I get from the DataSet to the response" is, "however
> you want to".
[quoted text clipped - 50 lines]
>
> John
fallenidol - 25 Oct 2006 07:54 GMT
you didnt say in your original post that you need it in a specific format
> Since Visual Studio cannot read my mind, how can I have it generate my
> SOAP response in the correct format?
[quoted text clipped - 27 lines]
>> > Thanks,
>> > LW