Announcement

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

    Changed DataSource from Servlet to REST call, changed URL but what else needs to change?

    I changed the DataSource from using a servlet to using a REST call. I just changed the url from the servlet to the REST endpoint and get the following error: Server returned TRANSPORT_ERROR with no error message. What other changes do I need to make to the DataSource when moving from a servlet to a REST call?

    #2
    This question doesn't make much sense - a REST endpoint is often implemented as a servlet.

    Perhaps take a step back and explain what you are trying to do?

    Comment


      #3
      My initial implementation of the DataSource extends javax.servlet.http.HttpServlet. My new DataSource is implemented as a org.springframework.web.bind.annotation.RestController. So, I changed the URL that is being accessed and get the TRANSPORT_ERROR message. Is there anything else that needs to be changed in the DataSource when going from HttpServlet to a RestController?

      initialDatasource = isc.DataSource.create({
      ID:"Info",
      dataFormat:"json",
      dataURL: "/project/actions/ProjectAction?action=info"
      });

      newDatasource = isc.DataSource.create({
      ID:"Info",
      dataFormat:"json",
      dataURL: "/projectBackend/api/info"
      });

      I hope this is clearer.
      Last edited by erik2000; 5 Jun 2020, 09:35. Reason: added more information

      Comment


        #4
        What this means is that DataSource calls your server and gets a transport error (like HTTP 500) so whatever you have at the URL, it's basically just crashing.

        You should probably start with the QuickStart Guide's chapter on Data Integration, also read this FAQ about why it's usually not a good idea to use a pre-existing REST service.

        Comment


          #5
          It's not a pre-existing REST service. I created the REST service. It works fine with Postman for example. Surely, DataSource can be used with REST services? And not just servlets?

          Comment


            #6
            Yes, of course DataSources work with REST services, there is even a RESTDataSource with a completely pre-built REST protocol, which is what we recommend you use.

            Also, there is no single REST protocol - we're guessing you may think there is. You definitely need to go back to the QuickStart Guide's Data Integration section, to understand how REST works and how SmartClient works with it.

            And again, servlets is a possible implementation of REST services - these are not two different things.

            Comment


              #7
              Can you point me to any examples or documentation using RESTDataSource in JavaScript?

              Comment


                #8
                Yes - start with the QuickStart Guide, Data Integration. There you will see an explanation of integration options and how to use RestDataSource.

                You should also make sure to review the QuickStart Guide, Data Binding chapter. It looks like you are asking for a running sample of RestDataSource, but that doesn’t make sense - all DataSources work the same way with components, so there would be nothing unique to RestDataSource to show. The QuickStart and it’s pointers into the SmartClient Reference provide copious documentation of the input and output formats you will need to process and produce in your server code.

                Comment


                  #9
                  I read through the QuickStart Guide and the section on Data Integration. I tried replacing DataSource with RestDataSource and it seems more successful. I have a new error message: "Transport error - HTTP code: 404 for URL: /projectBackend/api/info" So, it seems not able to find my REST service URL. I changed my JavaScript code to the following:

                  newDatasource = isc.RestDataSource.create({
                  ID:"Info",
                  dataFormat:"json",
                  fetchDataURL: "/projectBackend/api/info"
                  });

                  Am I missing something? Any suggestions on what might be wrong?

                  Comment


                    #10
                    404 is a response from your server saying there is nothing at that URL. So the URL is wrong.

                    It seems like you may not have worked with web technology before? We do offer training courses if you need more hands-on help. This forums is not the right place to try to learn about web basics, like what a 404 error means.

                    Comment


                      #11
                      At the same time, I can access that URL and the REST controller at that URL with Postman. So, the URL is working and correct. I have many years experience working with web technology. But this is my first time working with Isomorphic SmartClient.

                      Comment


                        #12
                        Then surely you have already looked in your browser’s developer tools and verified the request went to the specified URL, and you can take it from there.

                        Comment

                        Working...
                        X