This is a migrated thread and some comments may be shown as answers.

Implementing WebSevice with OpenAccess inside

9 Answers 140 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
tmlipinski
Top achievements
Rank 1
tmlipinski asked on 24 Feb 2009, 03:15 PM
Hi,

I have 2 projects:
- WebService - to perform all DAL and BLL functions
- web site - as a front end for this WebService

And some questions:

1. Data types conflict.
WebService has its asmx created by your wizard. It contains a method GetAllOrders that returns ChangeSet::

 

    using Telerik.OpenAccess;   
    namespace MyServiceSpace   
    {  
    [WebService(Namespace="MyServiceSpace")]   
    public class MyServiceClass : System.Web.Services.WebService   
    [WebMethod]   
    public ObjectContainer.ChangeSet GetAllOrders()  
    .... 

In the web site there is a Web Reference to this service - named MyServiceRef. And I try to execute GetAllOrders:
 

    using Telerik.OpenAccess;  
    ......  
    MyServiceRef.MyServiceClass srv = new MyServiceRef.MyServiceClass();   
    ObjectContainer.ChangeSet res = srv.GetAllOrders(); 

Oops - I get a compiler message: Cannot convert 'MyServiceRef.ChangeSet' to 'Telerik.OpenAccess.ObjectContainer.ChangeSet'

Why? How to avoid it? If I change the type of "res" to "object" it is performed successfully.

2. How to use ObjectProvider's ResultMethod type: Request?
As I understand this method is intended to make ObjectProvider (and ObjectView and RadGrid supplied with it) working with a WebService. So I've written (copying from your demo):
 

    ObjectProvider provider = new ObjectProvider();   
    provider.BaseType = typeof(PersistentClasses.Order);    // the definition of PersistentClasses is available in both projects   
    provider.RequestName = "MyServiceClass.GetAllOrders";   
    provider.ResultMethod = Telerik.OpenAccess.ObjectProvider.ResultMethodType.Request;
   
    provider.ResultName = "Orders";   
    provider.ObjectContextProviderTypeName = "???.MyObjectContainerProvider";    // here is the issue - see below   
    Telerik.OpenAccess.ObjectView view = new Telerik.OpenAccess.ObjectView();   
    view.ObjectProvider = provider;  
    view.RootType = typeof(PersistentObjects.Order); 

My WebService contains MyObjectContainerProvider class that is automatically generated by your tool (I've changed its default name). As I understand it should be possible to use this class, not a provider class defined in the web site project (another way it doesn't make sense to use the web service). But whatever I put instead of "???" I get a message that this provider cannot be found. Is it possible to use this provider from the web service - and how to declare it?

3. Using ObjectContainer - "best practices".
In your demo you use the method described above. But in the sample code from the Code Library (Working with Disconnected API using ObjectContainer) you use just another way. In terms of my example it would be:

 

    MyServiceRef.MyServiceClass srv = new MyServiceRef.MyServiceClass();   
    ObjectContainer container = new ObjectContainer();  
    container.Apply(srv.GetAllOrders());  
    RadGrid1.DataSource = container.Extent(typeof(PersistentClasses.Order)); 

What are the differences between these two methods? What are pros and cons in both cases?

Regards
Tomasz

 

 

 

 

 

 

9 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 27 Feb 2009, 04:47 PM
Hi tmlipinski,
You are getting the compile error because the web service import did generate a proxy object. The ChangeSet has a specific ctor to convert this. You can use:

ObjectContainer.ChangeSet cs = new ObjectContainer.ChangeSet(srv.GetAllOrders());

The generated methods for ObjectProvider and ObjectContainerProvider are there to let our wizards generate code that is working without any changes.

If you want to implement your own way you can use the ChangeSet directly. That makes also more sense because your code might be less complicated and better understandable.

Your code under (3) is the right one and with the indirection that I mentioned above it should work.

If you have more questions or want more details about our generated classes, please feel free to contact us again.

Kind regards,
Jan Blessenohl
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
tmlipinski
Top achievements
Rank 1
answered on 27 Feb 2009, 11:04 PM
Hi,

1. OK. It works. You should point it out in the documentation, examples and demos. (For those, who don't know what's going on with this proxy - see here). But it's an additional cost, alas - because it's a copy constructor. 

2. You haven't understand me. The key question is: is the ResultMethod.Request mode designed for driving ObjectProvider -> ObjectView -> RadGrid directly by a WebService, i.e. by setting the name of a method from this WS (RequestName) and the name of the object container provider also from this WS (ObjectContextProviderTypeName)?
If "yes": how to construct the ObjectContextProviderTypeName value in my case?
If "no": what is the anticipated usage of ResultMethod.Request?

3. This question is valid only if the answer for the above question is: "yes". In this case we have two methods for supplying RadGrid with data from a WebService. What is the difference between them? When to use one of them and when - another one?

Regards
Tomasz
0
Dimitar Kapitanov
Telerik team
answered on 06 Mar 2009, 07:13 AM
Hello tmlipinski,
Some more clarification to your question #2 and #3:

#2 - you have to include the assembly name as well, like "OpenAccessNorthwindMapping.ObjectScopeProvider1, OpenAccessNorthwindMapping" where the first part is the class name, and the second is the assembly name.

However I must add that this code is better to be generated with our wizards instead of manually crafting it.

#3 From our perspective you should use the second one - using ObjectContainer allows to implement in the correct manner the N-tier application scenario. You can use the ObjectContainer as a disconnected representation of the datastore that can transport data in the upper layers. On the other hand ObjectView is derived from the BindingSource class, which is a concrete Windows Forms implementation, thus is is not suitable for all types of scenarios.

Regards,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
tmlipinski
Top achievements
Rank 1
answered on 06 Mar 2009, 08:59 AM
Hello,

Thanks for the patience :-)

#3 - OK (although it should be clarified in the documentation and demos)
#2. I'm sorry but it still doesn't work. I've even done a trick: I've put in the code a direct call to some WS's method, stepped into it, checked under debugger the full name of the ObjectScopeProvider class and copied it into client-side parameters. And there is still the message: "Object Provider: Helper type xxx not found". I know that it's a kind of theoretic consideration (in the context of #3 explanation) but let's clarify it to the very end.

Regards
Tomasz
0
Dimitar Kapitanov
Telerik team
answered on 06 Mar 2009, 09:37 AM
Hi tmlipinski,
But do you have the helper class defined and working indeed? Do you have a reference to the enhanced assembly that contains the class in your references section of the .config file?

All the best,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
tmlipinski
Top achievements
Rank 1
answered on 06 Mar 2009, 09:48 AM
Hi,
This helper class is defined and working - but at the WS side, of course. It is not defined or directly referenced from the client side. If it should be - wouldn't it be a contradiction with the idea of WS?

Regards
Tomasz
0
Dimitar Kapitanov
Telerik team
answered on 06 Mar 2009, 11:51 AM
Hi tmlipinski,
Exactly that is the case. What I wanted to point at is that this operation is perfectly doable on the WS side and not on the client side. The reference could not be resolved on the remote side because you do not have the assembly loaded in the process, and if had it, why using service at all right? My suggestion supposed that you want to do it on the server side, but obviously that was not the case.

Greetings,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
tmlipinski
Top achievements
Rank 1
answered on 06 Mar 2009, 12:15 PM
Hi,

If so, let me summarize - correct me if I'm wrong:
- ResultMethodType.Request has nothing to do with WebServices
- it is designed to supply data by a named method of a named class from one of client's assemblies
Unfortunately, in your demos this method comes from a WebService.. which in this case is not a real WebService but just one of the assemblies. And that is why all that mess has come from.

Regards
Tomasz
0
Dimitar Kapitanov
Telerik team
answered on 09 Mar 2009, 08:33 AM
Hello tmlipinski,
The functionality in question can be used as a part of a WebService solution when you implement the WS proxies yourself. What we can do is to prepare extensive examples and documentation regarding this functionality soon after the Q1 2009 release. Hope that helps.

All the best,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
tmlipinski
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
tmlipinski
Top achievements
Rank 1
Dimitar Kapitanov
Telerik team
Share this question
or