1. I am testing out REST datasource using evaluation copy of smartgwtee5.0p. I insert a REST datasource in the sample project, buildinds. The file is country.ds.xml, reproduced below:-
<DataSource
ID="country"
dataFormat="JSON"
dataTransport="XMLHTTPREQUEST"
useStrictJSON="true"
dataURL="http://localhost:8980/RESTTEST/rest/RESTTESTService/countryFetch2"
recordName="country"
recordXPath="/response/ds/ds/country"
>
<fields>
<field name="countryCode" title="Code" type="text" primaryKey="true" required="true"/>
<field name="countryName" title="Name" type="text" />
<field name="continent" title="Continent" type="text"/>
</fields>
</DataSource>
2. When the fetch data is performed on this source, I got error: HTTP/1.1 405 Method Not Allowed. The following is log from eclipse:-
== 2015-03-07 17:03:07,087 [1-28] DEBUG PoolableDataSourceFactory - Activated DataSource 22 of type 'Object'
=== 2015-03-07 17:03:07,088 [1-28] DEBUG HttpProxyServlet - HttpProxy - ProxyData is: {
xsi:"http://www.w3.org/2000/10/XMLSchema-instance",
url:"http://localhost:8980/RESTTEST/rest/RESTTESTService/countryFetch2",
httpMethod:"GET",
params:{
},
requestBody:"",
callbackParam:""
}
=== 2015-03-07 17:03:07,225 [1-28] WARN HttpProxyServlet - HttpProxy - Method failed: HTTP/1.1 405 Method Not Allowed
=== 2015-03-07 17:03:07,226 [1-28] INFO HttpProxyServlet - HttpProxy - Response:
[WARN] 405 - POST /builtinds/sc/HttpProxy (127.0.0.1)
Request headers
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://127.0.0.1:8888/BuiltInDS.html?gwt.codesvr=127.0.0.1:9997
Accept-Language: en-GB,en;q=0.8,zh-Hant-HK;q=0.5,zh-Hant;q=0.3
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: 127.0.0.1:8888
Content-Length: 420
DNT: 1
Connection: keep-alive
Cache-Control: no-cache
Cookie: JSESSIONID=1757lmgjymb7a1kromcch6v6zl; isc_cState=ready; GLog=%7B%0D%20%20%20%20trackRPC%3Afalse%0D%7D
Response headers
X-Included-Test2: true
X-Included-Test: true
X-Proxied-Set-Cookie: JSESSIONID=7B1AA6D1D32A2ACB60167A631F0A9304; Path=/RESTTEST/; HttpOnly
Content-Length: 0
3. I use the same REST server with smartgwt RESTDataSource example, and it works there. The following is the eclipse console log when it works as a RESTDataSource:-
=== 2015-03-07 17:31:06,123 [4-28] DEBUG PoolableDataSourceFactory - Created DataSource 2 of type 'Object' and assigned it to thread qtp1940532364-28
=== 2015-03-07 17:31:06,123 [4-28] DEBUG PoolableDataSourceFactory - Created DataSource 2 of type 'Object' in the pooling flow
=== 2015-03-07 17:31:06,123 [4-28] DEBUG PoolableDataSourceFactory - Activated DataSource 2 of type 'Object'
=== 2015-03-07 17:31:06,131 [4-28] DEBUG HttpProxyServlet - HttpProxy - ProxyData is: {
xsi:"http://www.w3.org/2000/10/XMLSchema-instance",
url:"http://localhost:8980/RESTTEST/rest/RESTTESTService/countryFetch2",
httpMethod:"POST",
params:{
isc_dataFormat:"json"
},
contentType:"application/json",
requestBody:"{\r \"dataSource\":\"isc_RestfulDataSourceSample_1_0\", \r \"operationType\":\"fetch\", \r \"startRow\":0, \r \"endRow\":50, \r \"sortBy\":[\r \"countryCode\"\r ], \r \"textMatchStyle\":\"substring\", \r \"componentId\":\"isc_ListGrid_0\", \r \"data\":{\r }, \r \"oldValues\":null\r}",
callbackParam:""
}
=== 2015-03-07 17:31:06,264 [4-28] INFO HttpProxyServlet - HttpProxy - Method succeeded: HTTP/1.1 200 OK
=== 2015-03-07 17:31:06,265 [4-28] INFO HttpProxyServlet - HttpProxy - Response:
{"response":{"ds":{"ds":{"country":[{"countryCode":"CN","countryName":"China","continent":"AS"}]}}}}
=== 2015-03-07 17:31:06,266 [4-28] INFO Compression - /customds/sc/HttpProxy: 100 -> 88 bytes
4. I suspect that the problem is with the content-type specification when accessing it via ds.xml
[WARN] 405 - POST /builtinds/sc/HttpProxy (127.0.0.1)
Request headers
Accept: */*
Content-Type: application/x-www-form-urlencoded;
The content-type of x-www-form-urlencoded is not recognised by my REST server. I can confirm this using POSTMAN in Google.
When the call is successful via RESTDataSource, the contenttype is "application/json".
5. Is there a way to specify content-type with ds.xml? or you think the problem is somewhere else.
Thanks very much for your help
<DataSource
ID="country"
dataFormat="JSON"
dataTransport="XMLHTTPREQUEST"
useStrictJSON="true"
dataURL="http://localhost:8980/RESTTEST/rest/RESTTESTService/countryFetch2"
recordName="country"
recordXPath="/response/ds/ds/country"
>
<fields>
<field name="countryCode" title="Code" type="text" primaryKey="true" required="true"/>
<field name="countryName" title="Name" type="text" />
<field name="continent" title="Continent" type="text"/>
</fields>
</DataSource>
2. When the fetch data is performed on this source, I got error: HTTP/1.1 405 Method Not Allowed. The following is log from eclipse:-
== 2015-03-07 17:03:07,087 [1-28] DEBUG PoolableDataSourceFactory - Activated DataSource 22 of type 'Object'
=== 2015-03-07 17:03:07,088 [1-28] DEBUG HttpProxyServlet - HttpProxy - ProxyData is: {
xsi:"http://www.w3.org/2000/10/XMLSchema-instance",
url:"http://localhost:8980/RESTTEST/rest/RESTTESTService/countryFetch2",
httpMethod:"GET",
params:{
},
requestBody:"",
callbackParam:""
}
=== 2015-03-07 17:03:07,225 [1-28] WARN HttpProxyServlet - HttpProxy - Method failed: HTTP/1.1 405 Method Not Allowed
=== 2015-03-07 17:03:07,226 [1-28] INFO HttpProxyServlet - HttpProxy - Response:
[WARN] 405 - POST /builtinds/sc/HttpProxy (127.0.0.1)
Request headers
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://127.0.0.1:8888/BuiltInDS.html?gwt.codesvr=127.0.0.1:9997
Accept-Language: en-GB,en;q=0.8,zh-Hant-HK;q=0.5,zh-Hant;q=0.3
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: 127.0.0.1:8888
Content-Length: 420
DNT: 1
Connection: keep-alive
Cache-Control: no-cache
Cookie: JSESSIONID=1757lmgjymb7a1kromcch6v6zl; isc_cState=ready; GLog=%7B%0D%20%20%20%20trackRPC%3Afalse%0D%7D
Response headers
X-Included-Test2: true
X-Included-Test: true
X-Proxied-Set-Cookie: JSESSIONID=7B1AA6D1D32A2ACB60167A631F0A9304; Path=/RESTTEST/; HttpOnly
Content-Length: 0
3. I use the same REST server with smartgwt RESTDataSource example, and it works there. The following is the eclipse console log when it works as a RESTDataSource:-
=== 2015-03-07 17:31:06,123 [4-28] DEBUG PoolableDataSourceFactory - Created DataSource 2 of type 'Object' and assigned it to thread qtp1940532364-28
=== 2015-03-07 17:31:06,123 [4-28] DEBUG PoolableDataSourceFactory - Created DataSource 2 of type 'Object' in the pooling flow
=== 2015-03-07 17:31:06,123 [4-28] DEBUG PoolableDataSourceFactory - Activated DataSource 2 of type 'Object'
=== 2015-03-07 17:31:06,131 [4-28] DEBUG HttpProxyServlet - HttpProxy - ProxyData is: {
xsi:"http://www.w3.org/2000/10/XMLSchema-instance",
url:"http://localhost:8980/RESTTEST/rest/RESTTESTService/countryFetch2",
httpMethod:"POST",
params:{
isc_dataFormat:"json"
},
contentType:"application/json",
requestBody:"{\r \"dataSource\":\"isc_RestfulDataSourceSample_1_0\", \r \"operationType\":\"fetch\", \r \"startRow\":0, \r \"endRow\":50, \r \"sortBy\":[\r \"countryCode\"\r ], \r \"textMatchStyle\":\"substring\", \r \"componentId\":\"isc_ListGrid_0\", \r \"data\":{\r }, \r \"oldValues\":null\r}",
callbackParam:""
}
=== 2015-03-07 17:31:06,264 [4-28] INFO HttpProxyServlet - HttpProxy - Method succeeded: HTTP/1.1 200 OK
=== 2015-03-07 17:31:06,265 [4-28] INFO HttpProxyServlet - HttpProxy - Response:
{"response":{"ds":{"ds":{"country":[{"countryCode":"CN","countryName":"China","continent":"AS"}]}}}}
=== 2015-03-07 17:31:06,266 [4-28] INFO Compression - /customds/sc/HttpProxy: 100 -> 88 bytes
4. I suspect that the problem is with the content-type specification when accessing it via ds.xml
[WARN] 405 - POST /builtinds/sc/HttpProxy (127.0.0.1)
Request headers
Accept: */*
Content-Type: application/x-www-form-urlencoded;
The content-type of x-www-form-urlencoded is not recognised by my REST server. I can confirm this using POSTMAN in Google.
When the call is successful via RESTDataSource, the contenttype is "application/json".
5. Is there a way to specify content-type with ds.xml? or you think the problem is somewhere else.
Thanks very much for your help
Comment