Using Same Business Layer for SmartClient and WebClient

Topics: Web Client Software Factory
Feb 13, 2007 at 7:54 AM
I took the latest WCSF, and found out the Enterprise Library DLL's version was changed. Matias (http://staff.southworks.net/blogs/matiaswoloski/archive/2006/12/12/Web-Client-Software-Factory-Automation.aspx ) confirmed that one with WCSF is signed, and there is no functional change in the same.

I am trying to use the same business layer i made for Smart Client,
The seperate Business Layer contains Business Entities, Service Proxies, Service Agents and Translators as seperate projects. UI Layer consume these services, through Service Agents( After registering the same in UI layer). Now We want to use the same Business Layer through the Web Client. For that we have to have only one reference of Eterprise Lib, Object Builder Etc in this layer. And both Smart Client and Web Client shall use this layer.

The problem here is we were using Ent Lib DLL version 2.0.0.0 in Business Layer for smart client (till now) and as now for Web Client the version has changed... so we cannot use the business layer for both now.

For version 2.0.1.0
1) Smart client not working, Web Client working.

For version 2.0.0.0
1) Smart client working, Web Client not working.

So my questions is do i need to do something else in my UI/Business layer to use the new Strongly Typed Ent Lib dll (version 2.0.1.0)?

Is there any Demo Application which shall show the usage of ServiceProxy/ServiceAgent from Smart Client as well as Web Client? I hope am not asking for a lot... ;)

It shall be very helpful if someone would recommend any blog/post/white paper regarding the same.

Thanks Wali.
Feb 13, 2007 at 3:35 PM
I could successfully create a smart client solution with 2.0.1.0 enterprise library version.
To accomplish this, I changed the Location of Enterprise Library DLLs to “C:\Program Files\Microsoft Web Client Factory\Microsoft Practices Library” in the create solution wizard.

So, which exception are you getting while trying to use the 2.0.1.0 enterprise library version with the smart client solution?

Thanks,

Jonathan Menasches
http://staff.southworks.net/jony
Feb 13, 2007 at 4:15 PM
Its not a compile time problem. When call is made from Service Agent, The command shall get executed, but it does not come at the run method at all... And am not able to debug it at all...

Apparently its not going to Command.cs, CommandWithCallback.cs in service proxies project which has reference to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.

Do u have any idea, why its behaving the same?
Are you reusing the Business-Layer for Web Client?
Feb 15, 2007 at 3:53 PM
The problem you are having is not with Enterprise Library DLLs, it is with the service agent mechanism.

Service Agent mechanism was created for Smart Client applications to be more responsive, making it to consume services asynchronously.

What is happening to you in this case is that:

1. The client sends a request through a service agent.

2. As service agents work asynchronously the request to consume a service is delivered to the service agent queue.

3. A web page is shown on the client.

4. The service agent consumes the service.

5. The client never gets the response of the service.


This is why you cannot use Service Agent in Web Client the same way you used to use it in Smart Client.
What you could do to solve this is to bypass the service agent and consume the service directly.


Jonathan Menasches
http://staff.southworks.net/jony

Coordinator
Feb 15, 2007 at 6:26 PM
Another option would be to use the Web Service Software Factory's (WSSF) approach, which is what we did in the sample reference implementation.
Feb 16, 2007 at 6:35 AM
Edited Feb 16, 2007 at 6:50 AM
@Jony

I understood what you were trying to say. But if i change the ent lib dll(2.0.1.0) for Web Client and then call the service agent methods, i was successful in getting the callback with the proper data.

What is happening to you in this case is that:

1. The client sends a request through a service agent.
2. As service agents work asynchronously the request to consume a service is delivered to the service agent queue.
3. A web page is shown on the client.
4. The service agent consumes the service.
5. The client never gets the response of the service.

I agree to the point 1,2,3,4 that Web page is shown at the client before the service agent consumes the service. I am not agreeing to the point 5 as in my case am getting the response from the server. Both the things happen in different thread, but i thought that we can still manage to render the data in UI.

Coming on to your another point:-
"Service Agent mechanism was created for Smart Client applications to be more responsive, making it to consume services asynchronously."

Does this mean that we would make direct calls to service and work on synchronous mode for Web Client?

@Michael

We have already adapted to WSSF approach but still want to use Service Agent mechanism because:-
1) We are not exposing services directly to the client.
2) Asynchronous approach.

"Service Agent mechanism was created for Smart Client applications to be more responsive, making it to consume services asynchronously."

Do u agree with the above statement? If yes, then are we not targetting to work asynchronously in web-client? Cuz i feel there is equal need of Service Agents in WebClient.

Thanks for your comments, I am sure many people would have similar queries.
Coordinator
Feb 19, 2007 at 11:25 PM
The mechanisms that SCSF and WCSF (in the Reference Implementation) use to communicate to web services are different, and meant to fit into different architectures. For example, the SCSF service agent works in an asynchronous manner, for the occasionally-connected or disconnected scenario. However, in a web scenario, where pages, objects, and containers may only last for a moment, so we need to use a synchronous model.

If I were you, I would re-use your business entities and translators, and re-do the proxies and service agents to fit the synchronous model.