webservice plugin - way to query data without datasets?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
the webservice plugin offers a simple sql query execution interface (once you uncomment it) to allow remote extraction of data. curious if any thought has gone into how interfaces could be added for returning business object level data instead of plain datasets? Seems to break a lot of interfaces to allow a module to just execute any desired query...

I'd like to add something like a specific "GetOrders(OrderStatusFilter, maxrecords)" type of interface, which should be served well by using the existing business objects (and reduce risks), but not sure what the best route for serializing them for the webservice would be.
Il y a 12 ans
I think you should extend the web service plugin by adding new methods for loading orders. It's also recommended to create DTO objects for this purpose (for each entity you want to return).
http://en.wikipedia.org/wiki/Data_transfer_object
http://martinfowler.com/eaaCatalog/dataTransferObject.html
Il y a 12 ans
Do you think we can reuse some of the existing objects in Nop for the DTO purpose? maybe the Models?
Il y a 12 ans
Models, maybe (just add [Serializable] attribute). But I wouldn't do it because it's anti-pattern. I would better create new DTO classes
Il y a 12 ans
ok. i just see all the headache of keeping the current BO with mapping to the model objects, then to have to do this all over again for a webservice, sheesh. I'll dig into it a bit more, thanks.
Il y a 12 ans
For what it's worth, I'd create completely new DTO objects as AM mentioned.  Just adding an extra opinion...

Might also use the automapper to map the DTO's...?  Just a thought.  Less code.

-D
Il y a 12 ans
Will do. Actually I might just add some dataset returning methods initially, to get my dependent app up and running. Thanks guys.
Il y a 11 ans
Dear all I added the [Serializable] in the product class Nop.Core.Domain.Catalog.Product class as well as in Nop.Core.Baseentity class I also added the    [NonSerialized] in the fields of product class that I didn't want to be serialised.  And i tried to get a particular product from my client by extending web services and use a method like


        public Product GetProductCollection(string usernameOrEmail, string userPassword)
        {
            CheckAccess(usernameOrEmail, userPassword);
            if (!_permissionSettings.Authorize(StandardPermissionProvider.ManageCatalog))
                throw new ApplicationException("Not allowed to manage Catalog");

            return _productService.GetProductById(25);


        }


But it always fails with http error. Any help?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.