Silverlight call doesnt reach the server

Silverlight call doesnt reach the server

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


Peer posted on Tuesday, January 26, 2010

I’m working with the demo007 sample from video nTier Architecture to produce my own working project. I’ve created a BO CustomerList and made a test procedure to load the data. The test works fine, the GetCompanyList method is fired and result is returned.
The dataportal is outside the BO, just like demo007. The data portal is loaded by the factory and when I call the GetCompanyList(), the DataPortal.Fetch() statement invokes the Fetch method in the data access object .

What doesn’t work is the Silverlight call from my dataprovider:
ObjectType="Business.CompanyList, Business"
ManageObjectLifetime="True"
FactoryMethod="GetCompanyList"
IsInitialLoadEnabled="True" DataChangedHandler="{StaticResourceDataErrorDialog}">


The GetListCompany() method is invoked on the client side but the result is null:

public Csla.WcfPortal.WcfResponse EndFetch(System.IAsyncResult result) {
object[] _args = new object[0];
Csla.WcfPortal.WcfResponse _result = ((Csla.WcfPortal.WcfResponse)(base.EndInvoke("Fetch", _args, result)));
return _result;

I have no Idea how I have to solve this, How can I test the communication to the server? Im reading chapter 3 of the book in conjunction with the video’s and got stuck on this item.

Thank You
Peer

RockfordLhotka replied on Tuesday, January 26, 2010

If e.Object is null, then e.Error probably isn't. Check e.Error to see what exception is being thrown and see if that helps identify the issue.

Peer replied on Thursday, January 28, 2010

After a day (or two) of try and error communicating with the server I gave up and decided to postpone this issue. Maybe I should have some patience and read the next chapters in the book. I’m reading chapter 5-6-7-8 right now and meanwhile try to make my own BO’s (CompanyEdit) without a Silverlight interface.

Looking at sample Demo007 I implemented a Businessrule UniqueCId() which on his turn, instantiates a BO called CompanyCheckCid. This CheckBO has its own properties,client / server/dataacces version.

Is this “best practice” ? because from my perspective it is just a behavior from the CompanyEdit BO. Why extract this piece of functionality , I would implement a new method in the dataportal (factory object) e.g. isunique() or CheckUnique() in a general way because in my applications every rootobject has a kind of friendly key (often a string value) which is unique.

Is this structure possible and how should I implement this? Does it have big disadvantages?

In our former Framework (VFP, Mere Mortal by Kevin McNeish http://www.dotnetrocks.com/default.aspx?showID=55) we have implemented two layers on the framework, the first was "our" layer (adding extentions to the framework) where almost all the frameworks classes were subclassed, the second layer was the "application" layer where all the changes of the application were managed. On this second layer the application was build. Is this strategy also possible / recomendable with the CSLA framework ? This stategy would make it possible to implement my first question about the IsUnique() somewhere in the dataportal. In chapter 7 is explained how to deal with static properties in this subclassing scenario. I asume subclassing is a common practice to implement additional behaviour to the base classes.

Thanks!

Peer

RockfordLhotka replied on Thursday, January 28, 2010

People do modify the framework, usually only if they are happy to never upgrade though. You have to carefully consider changes to a framework with that in mind. CSLA 4.0, for example, will have a lot of changes in the data portal, meaning that if you alter the data portal in 3.x that you'll have to redesign your changes when you move to 4.0.

CSLA is extremely extensible and customizable, and usually people can extend the framework without altering it.

The data portal follows a "REST inspired" design, which says you have very limited numbers of verbs. Adding more verbs to the data portal is in direct contradiction to the philosophy it is designed around. Which means you can do such a thing, but at that point you are directly fighting against the philosophy of the framework design. That can only bring trouble and frustration.

If you have a global concept of a unique id, you should be able to create a common rule method that works against any object with an id. That may require the classes to implement a common interface so the rule can interact universally with all those types, but that's easily done.

The point I'm trying to make is that it should be a last resort to alter the framework. It should be near the last resort to extend it. Normally, especially for something as common as a unique id rule, you'll find that there's a way to implement the concept within the context and philosophy of the framework as it is.

Peer replied on Thursday, January 28, 2010

Thank You for your explanation! My goal is not altering the framework at all, I agree with you on all items, I just want a way to add our programming interface. Its all in a expirimental state with little .Net experience. Our team has a lot of VFP experience(#1 in Germany) and delivered their first SL project without any achitectural framework at all. We are figuring out what framework fits to our needs. At the end of this quarter we will make a shortlist with pro's and con's. The .Net (and CSLA) aproach is complete different from what we are used to ... Thanks for your patience :)

Peer

RockfordLhotka replied on Thursday, January 28, 2010

Happy to help as much as possible.

One thing with the data portal call - it is difficult to debug server calls when using pure XAML, because you are at the mercy of the XAML controls (CslaDataProvider or whatever).

For troubleshooting WCF connectivity issues, it is often better to do an explicit code call so you can get at the return values:

var dp = new DataPortal<TestItem>();
dp.FetchComplete += (o, e) =>
{
  // look at e.Error and e.Object here to
  // see what you get back from the call
};
dp.BeginFetch();

Peer replied on Friday, January 29, 2010

I implemented the code as you suggested, but without any clear result. The error which pops up is:

var dp = new DataPortal();
dp.FetchCompleted += (o, e) =>
{ object o1 = o;
object e1 = e;
};
dp.BeginFetch();
this.DataContext = dp;

e.error.message: Error = {System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details. ---> System.ServiceModel.CommunicationException: The remote server returned an error: NotFound....

Then I fixated the WCFport to 2466 in the property tab from the webproject.

For a short while I thought the problem was fixed when, after changing some databinding settings in the xaml, I actually got data back in my grid ! Huray, success at last.
Unfortunately the success disappeared as unexpected as it came … without changing any code or settings.

Then, after changing the code-behind a bit, the data returned again, but the next rime a ran the program it produced an error again. Restart in Debugmode would produce (sometimes) result but there is no consequent pattern. Still wandering why your samples are running fine I my project would not even load… Next week probably more success. Its probably a small trivial setting somwhere but it looks lik a needle in a haysteck

Have a nice Weekend

Peer

Peer replied on Wednesday, February 03, 2010

*** Victory at last! ***

Thanks to the bright view of my colegue (Sven J) we found the problem: A reference to a wrong type of Csla.dll. In the web project the Silverlight build version of the csla.dll was referenced instead of the .Net version.

I'm very supriesed the compiler didn't' noticed the wrong version of the DLL, it is build for Silverlight only ?

I'm testing the Unique procedure from Demo007 and wander why in my testproject the update method in the objectfactory isn't called (breakpoint doesn't fire).... Instead the validation returns an error:


"Test method Business.Test.CompanyTest.CompanyEditTest threw exception: Csla.Validation.ValidationException: Objects that are marked busy may not be saved. "


The validation part on the client is triggered twice.

I see no difference in the code from Demo007 and my testproject, but there will be probably be slight one which slipped to my attention.

Thanks ;)
Peer

Copyright (c) Marimer LLC