How to Provide Network Credentials with DSA Request

Topics: CAB & Smart Client Software Factory
Jul 23, 2007 at 3:21 AM
In the DisconnectedServiceAgent Quickstart, the following method enques a request for menu items via the Agent class:

public void TryGetMenuItems()
{
if (Connected)
{
OnLongProcess(true);
OnStatusUpdate(Resources.RetrievingMenuItems);
restaurantService.GetMenuItems(restaurant.Identifier);
}
else
{
// If the application is not online, update the view to show an offline message
View.ShowOfflineMessage();
}
}

I'm trying to use this technique to retrieve a list of reports from SQL Server Reporting Services.
If I enque a request to the ListChildren method of the Agent created from a ReportService2005 proxy class shown below, I get an unthorized 401 exception via the method callback.

string reportPath = "/";
bool recursive = true;
_reportingService.LogonUser("user", "password", "domain");
_reportingService.ListChildren(reportPath, recursive);

The exception occurs for both the LogonUser method as well as the ListChildren method and I show the second exception below:

The request failed with HTTP status 401: Unauthorized.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at CDSA.WebServiceProxies.ReportService2005.ReportingService2005.ListChildren(String Item, Boolean Recursive) in F:\Code\RStafford\SASSY\Source\Application\WebServiceProxies\Web References\ReportService2005\Reference.cs:line 871

I tried to use the LognUser method but that throws the same Unauthorized exception.
I've created an Endpoint with username, password and domain for the ReportingService but I'm not clear how to associate the endpoint credentials with the enqued request using the Agent methods.

I don't have any trouble getting a list of reports directly when Online. I just use:

CDSA.WebServiceProxies.ReportService2005.ReportingService2005 rs = new CDSA.WebServiceProxies.ReportService2005.ReportingService2005();
NetworkCredential credentials = new NetworkCredential("user", "password", "domain");
rs.Credentials = credentials;

CatalogItem[] items = rs.ListChildren(reportPath, true);

How can I avoid the Unauthorized exception and pass the necessary credentials?

Much Thanks,

Chris Smith