My website authenticates a Tessitura session key under an anonymous constituent, and it later allows the user to log in, calling TransferCart() to associate the cart with the newly-authenticated user. This generates an error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Order does not exist
I must be using TransferCart() wrongly, but I can't figure out how. Here's the code:
WebReference.Tessitura client = new WebReference.Tessitura(); string sessionKey = client.GetNewSessionKey(""); client.LoginEx2( sessionKey, anonymousUsername, anonymousPassword, 1, 0, "", "", "", 0, 0, ""); client.LoginEx2( sessionKey, constituentUsername, constituentPassword, 1, 0, "", "", "", 0, 0, ""); client.TransferCart(sessionKey);
If I comment out the last line, which calls TransferCart(), then the code runs without a hitch. I'm at a loss.
Thanks,Bryan
I believe that unless something is added to the cart it won't work. It looks like in this case you should either wait to call TransferCart or use TransferSession
I think I've got this right now, but I'd like to post my strategy to see if anyone can think of a better way.
Yes, a cart must have existed for the anonymous user in order to call TransferCart() without generating an exception. Therefore, you have to either catch and ignore this exception, or detect whether a cart exists.
In order to detect the existence of a cart, I am using the following:
DataSet cart = Tessitura.Tessitura.GetCart(sessionKey); bool cartExists = cart.Tables["Order"].Rows.Count > 0;
Does anyone have a different or better way of accomplishing this?