REST API
Posted in 2016
Topics: Storage & Space Management, Connectivity: ODBC / JDBC / .NET, Server Administration, Security, Permissions & Auditing, Networking & sqlhosts Configuration, Java & JDBC Development, Internationalization & Character Sets, Versions, Editions & End-of-Life
Hi all
INFORMIX VERSION:
Inst_1: onstat -version
Program Name:onstat
Build Version:12.10.FC6AEE
Build Number:N253
Build Host:lxvm-l172
Build OS:Linux 2.6.18-128.el5
Build Date:Wed Nov 4 21:57:33 CST 2015
Build Timestamp:2015-11-04T21:30:00-06
GLS Version:glslib-6.00.FC7
ENVIRONMENT SETTING:
Inst_1: env | egrep "INFORMIX|ONCONFIG"
INFORMIXDIR=/opt/informix_12_1xc6
ONCONFIG=onconfig.dbserver_tcp
INFORMIXCONTIME=15
INFORMIXSERVER=dbserver_tcp
INFORMIXSQLHOSTS=/opt/informix_12_1xc6/etc/sqlhosts
OUTPUT OF /etc/hosts
Inst_1: cat /etc/hosts | egrep -v "^#|^$"
127.0.0.1 localhost
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
127.0.0.2 ifmx-server
OUTPUT OF onstat g ntt
Inst_1: onstat -g ntt
IBM Informix Dynamic Server Version 12.10.FC6AEE -- On-Line -- Up 04:19:03 --376676 Kbytes
global network information:
#netscb connects read write q-free q-limits q-exceed alloc/max
2/ 4 20 14950 14983 2/ 2 135/ 10 0/ 0 2/ 2
Individual thread network information (times):
netscb thread name sid open read write address
45823b88 soctcplst 3 16:28:31 18:15:14 ifmx-server|49000|soctcp
458211c0 soctcppoll 2 17:05:07
SQLHOST SETTING:
Inst_1: cat $INFORMIXSQLHOSTS | egrep -v "^#|^$"
dbserver_tcp onsoctcp ifmx-server 49000
dbserver_shm onipcshm ifmx-server 9088
dbserver_dr drsoctcp ifmx-server 9099
UNIX LEVEL CONNECTIVITY:
Inst_1: ping ifmx-server
PING ifmx-server (127.0.0.2) 56(84) bytes of data.
64 bytes from ifmx-server (127.0.0.2): icmp_seq=1 ttl=64 time=0.039 ms
64 bytes from ifmx-server (127.0.0.2): icmp_seq=2 ttl=64 time=0.052 ms
64 bytes from ifmx-server (127.0.0.2): icmp_seq=3 ttl=64 time=0.051 ms
64 bytes from ifmx-server (127.0.0.2): icmp_seq=4 ttl=64 time=0.050 ms
--- ifmx-server ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.039/0.048/0.052/0.005 ms
Inst_1: hostname
ifmx-server
TEST THE DB CONNECTIOB USING dbaccess
Inst_1: echo "select * from customer where customer_num=101" | dbaccess stores
Database selected.
customer_num 101
fname Ludwig
lname Pauli
company All Sports Supplies
address1 213 Erstwild Court
address2
city Sunnyvale
state CA
zipcode 94086
phone 408-789-8075
1 row(s) retrieved.
TAKING THE FACT THE there are some packaging issue note at:
https://www.ibm.com/developerworks/community/blogs/smoe/entry/Authentication_wit
h_the_Informix_REST_Listener?lang=en
I extracted the file tomcat-embed-core.jar from my old V12.10xC4
(nosql_sdk.zip) and placed it at $INFORMIXDIR/bin directory.
ENSURE RESPECTIVE FILE ARE AVAILABLE:
Inst_1: ls -l $INFORMIXDIR/bin/tomcat-embed-core.jar
-rwxr-xr-x 1 informix informix 2668652 2016-01-18 16:14
/opt/informix_12_1xc6/bin/tomcat-embed-core.jar
Inst_1: ls -l $INFORMIXDIR/bin/jsonListener.jar
-rwxr-xr-x 1 informix informix 15803625 2015-11-04 22:02
/opt/informix_12_1xc6/bin/jsonListener.jar
REST API CONFIG FILE:
Inst_1: java -cp
$INFORMIXDIR/bin/jsonListener.jar:$INFORMIXDIR/bin/tomcat-embed-core.jar
com.ibm.nosql.server.ListenerCLI -config
$INFORMIXDIR/etc/jsonListener-rest.properties -logfile
/home/informix/logs/jsonListener-rest.log -start &
Inst_1: cat $INFORMIXDIR/etc/jsonListener-rest.properties | egrep -v "^#|^$"
authentication.enable=false
authentication.localhost.bypass.enable=true
database.dbspace=rootdbs
database.locale.default=en_US.819
listener.idle.timeout=60000
listener.port=30001
listener.type=rest
listener.commands.enable=true
response.documents.count.maximum=1000
security.sql.passthrough=true
url=jdbc:informix-sqli://ifmx-server:49000/sysmaster:INFORMIXSERVER=dbserver_tcp
;USER=informix;PASSWORD=password;INFORMIXCONTIME=15
Start the wireless listerner:
Inst_1: java -jar $INFORMIXDIR/bin/jsonListener.jar -config
$INFORMIXDIR/etc/jsonListener-rest.properties -logfile
/home/informix/logs/jsonListener-rest.log -start &
[1] 7606
Inst_1: starting rest listener on port 30001
Check the log:
Inst_1: cat /home/informix/logs/jsonListener-rest.log
{ "date": "2016-01-18 21:44:12.811" , "thread": "main" , "level": "INFO " ,
"source": "com.ibm.nosql.server.ListenerCLI" , "message": "build information"
, "data": { "version" : "1.2.0-SNAPSHOT" , "informixVersion" : "12.10.xC6" ,
"buildType" : "local" , "buildLabel" : "201511031758" , "buildEngineHostName"
: "hans" , "buildEngineId" : "" , "buildDescription" : "" ,
"repositoryAddress" : "local" , "jdbcDriverVersion" : "4.10.JC4N900" } }
{ "date": "2016-01-18 21:44:12.998" , "thread": "main" , "level": "WARN " ,
"listenerId": 1 , "source": "o.a.catalina.core.StandardContext" , "message":
"A context path must either be an empty string or start with a '/' and do not
end with a '/'. The path [/] does not meet these criteria and has been changed
to []" }
{ "date": "2016-01-18 21:44:13.415" , "thread": "main" , "level": "INFO " ,
"listenerId": 1 , "source": "o.a.coyote.http11.Http11NioProtocol" , "message":
"Initializing ProtocolHandler ["http-nio-127.0.0.1-30001"]" }
{ "date": "2016-01-18 21:44:13.468" , "thread": "main" , "level": "INFO " ,
"listenerId": 1 , "source": "o.a.tomcat.util.net.NioSelectorPool" , "message":
"Using a shared selector for servlet write/read" }
{ "date": "2016-01-18 21:44:13.469" , "thread": "main" , "level": "INFO " ,
"listenerId": 1 , "source": "o.a.catalina.core.StandardService" , "message":
"Starting service Tomcat" }
{ "date": "2016-01-18 21:44:13.469" , "thread": "main" , "level": "INFO " ,
"listenerId": 1 , "source": "o.a.catalina.core.StandardEngine" , "message":
"Starting Servlet Engine: Apache Tomcat/8.0.28" }
{ "date": "2016-01-18 21:44:13.589" , "thread": "main" , "level": "INFO " ,
"listenerId": 1 , "source": "o.a.coyote.http11.Http11NioProtocol" , "message":
"Starting ProtocolHandler ["http-nio-127.0.0.1-30001"]" }
{ "date": "2016-01-18 21:44:13.593" , "thread": "main" , "level": "INFO " ,
"listenerId": 1 , "source": "c.ibm.nosql.server.rest.RestListener" ,
"message"
Original post: <stuff removed> ... Questions 1) Why the wireless listener accepting connection from the local host(127.0.0.1) instead of ifmx-server(127.0.0.2) ? 2) Why I can not query by a single record(in test 3), anything wrong with the syntax or setting or the wireless config file ? Seeking quick respond on this matter. Thanks Response: Well, I think the answer to 1 is you need to modify/set the value of listener.hostName in your wire listener properties file...here is it's commments from the file: ## Key: listener.hostName ## Type: string ## Default: localhost ## Description: The host name of the JSON listener. # # This determines the network adapter/interface that the listener binds the server socket to. # If set to *, the listener will bind to all interfaces/addresses. # # listener.hostName=localhost So I beleive you would want to either set it to "*" (to get all interfaces) or use tho hostname "ifmx-server". It doesn't say it's default value, but it would seem like it's default is localhost. Jacques Renaut IBM Informix Advanced Support APD Team
Original post: <stuff removed> Questions 1) Why the wireless listener accepting connection from the local host(127.0.0.1) instead of ifmx-server(127.0.0.2) ? 2) Why I can not query by a single record(in test 3), anything wrong with the syntax or setting or the wireless config file ? Seeking quick respond on this matter. Thanks Response: Ok, so for question 2...holy cow figuring out the correct syntax for curl was a pain. I was able to get the single query to work using the following curl syntax: curl -X GET -i "http://localhost:17830/stores_demo/customer?query=\\\\{customer_num:101\\\\}" So had to add quotes around the entire url and then escape the {}'s for the filter...but after doing that, my curl output was this: curl -X GET -i "http://localhost:17830/stores_demo/customer?query=\\\\{customer_num:101\\\\}" ... Transfer-Encoding: chunked Date: Tue, 19 Jan 2016 20:23:52 GMT [{"customer_num":101,"fname":"Ludwig","lname":"Pauli","company":"All Sports Supplies","address1":"213 Erstwild Court","address2": null ,"city":"Sunnyvale","state":"CA","zipcode":"94086","phone":"408-789-8075"}] Jacques Renaut IBM Informix Advanced Support APD Team
Thanks for the quick respond. Both issue has been resolved now. Cheers
Related threads
- TABLE AN INDEX REORG
- ROLE FOR USERS
- HDR in Windows
- eliminate duplicate rows
- Fragmentation Elimination Problem