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?
Announcement
Collapse
No announcement yet.
X
-
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.
Comment
-
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
-
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
-
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
-
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
-
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
Comment