Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RestDataSource requests as XML in POST

    Currently I am using the RestDataSource with the default get- and postparams, but I would like to receive the requests in XML format on the server.

    As I understood from the documentation this should be done by providing OperationBindings on your (Rest)DataSource with the DSDataProtocol.postXML or DSDataProtocol.postMessage value.

    This does change the behaviour in using a POST instead of a GET for fetch operations for instance, but no XML request is included in the requestbody?

    Am I overlooking something? Is there any example for this? Using XML requests a much cleaner integration could be accomplished for our implementation.

    #2
    The enum values for DSProtocol have the wrong case "postxml" instead of "postXML". I'll correct this in tonights build.

    In the mean time you could try the following :

    Code:
    OperationBinding addBinding = new OperationBinding();
    addBinding.setOperationType(DSOperationType.ADD);
    addBinding.setAttribute("dataProtocol", "postXML");
    ...
    ...
    Sanjiv

    Comment


      #3
      The enum value has been fixed in the 11-24-2008 build. I tried setting the dataprotocol as postXML and it works fine now.

      Sanjiv

      Comment


        #4
        Do all operation types need to use the same DSProtocol?

        Hello Sanjiv,

        When testing I found out that when providing operation bindings for all operation types it only seems to use the last one for all operation types (fetch, add, update, remove)? Should all operation types use the same DSProtocol (by specification)? Or should it be possible to use a different DSProtocol for each operation type (the API gave that impression to me).

        Comment


          #5
          Hi teseling,

          You are intended to be able to use a mixture of protocols. Can you show your code for creating the operationBindings?

          Comment


            #6
            Here are some parts of the code I am using (although I have tried some variations):

            Code:
            public class ItemDataSource extends RestDataSource {
            
                ...
            
                public ItemDataSource(String id) {
                    setID(id);
                    setDataFormat(DSDataFormat.XML);
                    setRecordXPath("/item");
            
                    setOperationBindings();
                    OperationBinding fetch = new OperationBinding();
                    fetch.setOperationType(DSOperationType.FETCH);
                    fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
                    OperationBinding add = new OperationBinding();
                    add.setOperationType(DSOperationType.ADD);
                    add.setDataProtocol(DSProtocol.POSTMESSAGE);
                    OperationBinding update = new OperationBinding();
                    update.setOperationType(DSOperationType.UPDATE);
                    update.setDataProtocol(DSProtocol.POSTMESSAGE);
                    OperationBinding remove = new OperationBinding();
                    remove.setOperationType(DSOperationType.REMOVE);
                    remove.setDataProtocol(DSProtocol.POSTMESSAGE);
                    setOperationBindings(fetch, add, update, remove);
            
                    setDataURL("some_data_url");
                }
            }
            This code works because they all use the DSProtocol.POSTMESSAGE. If I change for instance the fetch operation binding to GETPARAMS (or anything else) it still keeps using the POSTMESSAGE. As far as I was able to determine this seems to be because the last binding uses POSTMESSAGE? Thanks for looking into it.

            Comment


              #7
              Overriding transformRequest

              One other question would be about the way to override the transformation as described in javadoc.

              http://www.smartclient.com/smartgwt/doc/javadoc/com/smartgwt/client/data/RestDataSource.html

              When I override the transformRequest() methode it does not seem to get called when processing the request. I am using POSTMESSAGE as described in code sample above (see previous message) and I do get a normal XML request message so the standard transformation is ok. The reason I want to do this is to add some paramaters into the request like sessionId.

              Comment


                #8
                The transformRequest() API isn't there yet in SmartGWT - expect it in an upcoming nightly build.

                Comment


                  #9
                  It would be great if that could be added soon. We need to adapt the XML in the requests that the datasource is sending to the server and are looking for a good solution. Thanks in advance.

                  Comment


                    #10
                    Override point DataSource.transformRequest(..) has been added to build 12-04-2008.

                    Sanjiv

                    Comment


                      #11
                      Thanks! I will try it immediately.

                      Comment


                        #12
                        Missing methods

                        First of all, thanks a lot for all the work on SmartGWT. I appreciate it a lot.

                        It still seems as if there are a few pieces missing in the SmartGWT version of RestDataSource to make it really usable.
                        1. setting the httpMethod on a OperationBinding (e.g. setRequestProperties())
                        2. String getDataURL(DSRequest request) to return dynamic URLs


                        [1] Replicating the following recommendation from RestDataSource
                        Code:
                        operationBindings:[
                            {operationType:"fetch", dataProtocol:"getParams"},
                            {operationType:"add", dataProtocol:"postParams"},
                            {operationType:"remove", dataProtocol:"getParams", requestProperties:{httpMethod:"DELETE"}},
                            {operationType:"update", dataProtocol:"postParams", requestProperties:{httpMethod:"PUT"}}
                        ],
                        [2] Returning URL based on request data with templates.
                        This requires overriding getDataURL(DSRquest request) to expand the variables in the template with the supplied request data.

                        I'd like to "bump" Issue 8. It would be great if it could be added in one of the next few builds.

                        Comment


                          #13
                          There is a reason to call it junk mail - as much as 99 percent of direct mail ads are ignored or abused before they (Buy WOW Gold) thrown in the trash. But Shawn Burst saw the midst of the redeemed coupons (Buy Aion Gold) potential and "Only in this week!" Offers: What if it was possible to combine a direct-mail campaign with social media and other Web technologies? What if he could junk mail very valuable - not only for the people who get fast WOW Gold, but also the marketing groups and companies that send it? Two years ago, burst Dukky, a company (Aion Leveling)dedicated to precisely this idea. After 15 years in the direct mail and printing industry in New Orleans, did burst, the most effective campaigns that have a good offer (WOW Power Leveling) and a good mailing list. But he also knew that even the best of strong customer loyalty and really lacked measurable results.

                          Comment

                          Working...
                          X