Problems with setting up WebServiceHosting

Problems with setting up WebServiceHosting

Old forum URL: forums.lhotka.net/forums/t/2996.aspx


gartnerj posted on Thursday, June 07, 2007

Folks,

this is my first time through with using CSLA, and I have a bunch of BO's working when running locally using a DAL/DTO layer to connect to a db.

I now want to use a Web Service Host (or maybe a remoting host) to serve the BO's for an application.

 

I built the WebServiceHost as per the example ProjectTracker and installed on a dev IIS server.

I updated the app.config of the client to have this:

<add key="CslaAuthentication" value="Csla" />
 <add key="CslaDataPortalProxy"
      value="Csla.DataPortalClient.WebServicesProxy, Csla"/>
    <add key="CslaDataPortalUrl"
      value="http://DEVIISMACHINE/Moodys.Epi2.BO.WebServicesHost/BOWebServicePortal.asmx"/>

The app first gets this when trying to connect at this line in the WebServicesProxy:

result = Deserialize(wsvc.Fetch(Serialize(request)));

I get:

Principal must be of type BusinessPrincipal, not System.Security.Principal.GenericPrincipal

 

I added this to the client:

 

PTPrincipal.Logout();

PTPrincipal.Login("user", String.Empty);

 

This PtPrincipal is an exact copy from ProductTracker, except I just return true and a default role -- I don't actually authenticate anything at this point.

Once I add that, I now get this as an error (remember, the Serialize is on the PTPricipal class):

 Object of type 'System.Runtime.Serialization.TypeLoadExceptionHolder' cannot be converted to type 'System.Security.Principal.IPrincipal'.

It looks like it is complaining about the PTPricipal passed to the webservicehost, but I'm not sure what to do at this point.  The WebServiceHost Web.Config also has :

<appSettings>

<add key="CslaAuthentication" value="Csla" />

and i have tried authentication="Windows" (with impersonate true), and authentication="none", but these don't change the problem (I didn't really expect it would).

Any help would be greatly appreciated!!

gartnerj replied on Friday, June 08, 2007

OK folks, I found out the issue (just adding this in case other beginners run into the same issues).

The actual error returned as :  Object of type 'System.Runtime.Serialization.TypeLoadExceptionHolder' cannot be converted to type 'System.Security.Principal.IPrincipal'

Had nothing to do with the PTPrincipal or the login id at all.  It was a different class (buried deep in my DAL/DTO Layer that I use instead of coding the SQL directly in the BO's) that had a deserialization problem -- it's just that it showed up with THIS error message -- somewhat misleading, but that's how it goes.

Anyway, just completing this post for anyone else having the issue.

Joe replied on Monday, December 17, 2007

I know this is an old thread, but I'm getting the exact same error message while doing some unit testing in VS 2008.  I'm trying to track down the exception; any suggestions where to look?

Is the exception actually related to Principal/Identity/Login issues?  Does it occur somewhere in the CSLA framework or was it elsewhere?  Was it simply a matter of a BO not being marked as serializable, or perhaps it had unserializable member variables?

Any help would be appreciated.  Thanks!

~Joe

RockfordLhotka replied on Monday, December 17, 2007

This exception does come from CSLA - from the data portal. The server-side data portal will only run if a valid (though it could be unauthenticated) principal object is provided from the client.

Both client and server must use the same CslaAuthentication setting in their config files. And the client must set its principal to a valid (if unauthenticated) principal before any data portal call - including one to set up the principal.

Copyright (c) Marimer LLC