Paul Galvin's (old) SharePoint space [SharePoint

Just another WordPress.com site

Invoking SSRS Web Services From WSS / MOSS in FBA Environment

We needed to invoke the "CreateSubscription" method on an SSRS web service that is hosted in an FBA managed MOSS environment from a custom web part.  We kept getting variations of:

  • 401: Not authorized
  • Object Moved

The "object moved" message was most interesting because it was saying that the "object" (our SSRS service) had "moved" to login.aspx.  This clearly meant we had some kind of authentication problem.

I eventually realized that I had bookmarked a blog entry by Robert Garret that described how to invoke a general purpose WSS/MOSS web service living inside an FBA environment.  Note that I can’t link directly to the article (as of 06/09/08) because it wants to authenticate.  The link I provide brings you to an "all posts" view and you can locate the specific article by searching for "Accessing MOSS Web Services using Forms Based Authentication".

Here’s the code that worked for us:

ReportingService2006 rs = null; 
// Authenticate Authentication auth = new Authentication(); 
auth.Url = "http://URL/_vti_bin/Authentication.asmx";
auth.CookieContainer =
new CookieContainer();
LoginResult result = auth.Login("userid", "password");
if (result.ErrorCode == LoginErrorCode.NoError) 
{
// No error, so get the cookies.
CookieCollection cookies = auth.CookieContainer.GetCookies(new Uri(auth.Url));
Cookie authCookie = cookies[result.CookieName];
rs =
new ReportingService2006();
rs.Url =
"http://server/_vti_bin/ReportServer/ReportService2006.asmx";
rs.CookieContainer =
new CookieContainer();
rs.CookieContainer.Add(authCookie);
}
try
{
  rs.CreateSubscription(report, extSettings, desc, eventType, matchData, parameters1);
}
catch (Exception ex)
{
  Console.WriteLine(ex.Message.ToString());
}

I interpret things to work like this:

  • Our web part needs to dial up the authentication service and say, "Hey, Tony, it’s me!".
  • Authentication service replies saying, "Hey, I know you.  How are the kids?  Here’s a token."
  • We call up the SSRS service and say, "Tony sent me, here’s the token."

</end>

Subscribe to my blog.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: