IBM Worklight - initialization at application server startup - service

I am new to IBM Worklight.
I implemented a simple IBM Worklight HTTP servie adapter. This adapter needs some data from server database which remains constant for all calls to this service adapter.
Fetching that data every time the adapter is called, is overhead. So I want to cache those values when the IBM Worklight server is started for first time and use them for each call to adapter.
I could not figure out how to do this? Any help greatly appreciated.

If you're looking to do client side caching then I would suggest using JSONStore: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v506/05_08_JSONStore_-_The_client_side_JSON_based_database_overview.pdf.
When your app starts, you can check if the data has been saved in your local storage. If it does not exist, fetch the data from the adapter and then save it locally. On each http adapter invocation, the client will have the constant data needed.
My answer is making the assumption that you need the data cached for the client to make the adapter call. If you have a worklight adapter that is getting data from another worklight adapter, then you'll need a different solution.

Related

SAP DI Server - How to issue first request?

I have set up a Windows server using SAP Business One, and am trying to fire up the DI Server.
I would like to make a HTTP request with a SOAP body, but I don't know what URL to put in postman.
I also can't figure out how to run the example files in the installation folder for DI Server.
Does anyone know how to get started with DI Server?
Unless you are also using B1WS, starting the DI-Server service doesn't give you a listening HTTP server. You need to write your own listener, for instance as a simple .ashx page hosted under IIS, which accepts a request and passes it to the Interact method of the SBODI_Server.Node object.
See: https://blogs.sap.com/2014/07/28/connecting-an-add-on-to-sap-business-one/

How can session cache service data be stored externally?

Cross-posting as advised from DeveloperWorks: https://developer.ibm.com/answers/questions/212469/can-an-application-hosted-outside-bluemix-access-s.html
I am exploring a scenario wherein I have an existing Java application hosted on-premises outside BlueMix. I want to make it horizontally scalable. As part of this change I would like to know if I can provision a BlueMix Session Cache service to store the application's session state externally. The application will continue to be hosted outside BlueMix but use BlueMix Session Cache for session state management.
It is not possible at the moment.
Although a person can setup a Liberty runtime with the right connection information copied from VCAP and runtime variables, and use it to host a web application that use session cache client, this machine is outside Bluemix and won't be trusted by the network. As a result, it won't be able to connect to the session cache within Bluemix.

How to establish connection between db and java code in bluemix

I am making a web application in bluemix and for that, I chose java db web starter as boiler plate. I made html files in eclipse and I want db connectivity. I made a table in database (viz userInformation), but I am not getting that where and what code should be written to establish connection. Please help.
If you're deploying a Liberty application, and using the SQLDB service, the connection information and the db driver jar should be automatically configured in the server.xml and a datasource is created for you. You can access it using JNDI. Take a look at this example:
https://developer.ibm.com/bluemix/2014/02/07/java-db2-10-minutes/
Your other option is to parse the VCAP_SERVICES environment variable and read the connection information out of it. Example: https://github.com/IBM-Bluemix/get-started-java
The Bluemix documentation has a lot information on how to make the connection for each services.
Also, you will need to have some server side java code like a Servlet to make this db connection. You can not connect directly from your client side html code.
https://github.com/IBM-Bluemix/java-db

How to test connectivity to couchbase server using .NET sdk?

I'm trying to test connectivity to couchbase server using the .NET sdk.
I've tried to get a test key in order to do it, but I'm getting "null" (instead of getting an exception mention that couchbase server is done).
I've also read this:
http://www.couchbase.com/docs//couchbase-manual-2.0/couchbase-getting-st...
But it doesn't say anything about testing connectivity from an application code.
Is there any way of testing connection to couchbase server via code ?
The couchbase client sdk manages the connections for you, whatever node urls you pass to it during construction it attempts to authenticate to, if the client can't authenticate to one of the nodes then it throws ConnectException (I'm using the JAVA sdk but I imagine .NET is very similar).
So really you don't have to test the connectivity, the smart client handles that. After construction you can ask the client to list all the available servers
client.getAvailableServers();
Or for a more detailed status of your nodes and statistics do:
client.getStats();

What is the difference between IBM HTTP Server vs Wepsphere Application Server?

I would like to know the difference between IBM HTTP Server and Wepsphere Application Server. Also i am planning to use WAS. Do i still need the IBM HTTP Server?
From here:-
IBM HTTP Server
IBM® HTTP Server is a full-featured web server that is included with
other products such as IBM WebSphere® Application Server at no charge.
You can use this web server for projects that do not warrant the
expense of a priced and supported HTTP server. The IBM HTTP Server is
based on the Apache HTTP Server and provides a rich set of Apache
features in addition to IBM enhancements.
From here:-
Wepsphere Application Server
IBM® WebSphere® Application Server offers options for a faster, more
flexible Java application server runtime environment with enhanced
reliability and resiliency. It supports single server environments and
medium-sized configurations, as well as dynamic web applications
requiring web tier clustering over multiple application server
instances.
Do i still need the IBM HTTP Server?
Wiki has the answer for it:-
It works with a number of Web servers including Apache HTTP Server,
Netscape Enterprise Server, Microsoft Internet Information Services
(IIS), IBM HTTP Server for i5/OS, IBM HTTP Server for z/OS, and IBM
HTTP Server for AIX/Linux/Microsoft Windows/Solaris. It uses port 9060
for connection as the default administration port and port 9080 as the
default website publication port. In case you install more WebSphere
instances these values will be changed.
A http server is used for routing web requests to a WAS in a typical enterprise scenario. If you are building small apps, and do not need ejbs, just use the http server. If you need ejbs, just use WAS. However, if you need functionality like routing requests to WAS because you do not want the user to hit the WAS directly for security reasons, then use HTTP in front of WAS.
WebSphere is an implementation of J2EE (originally Java 2 but versions handle up to J6EE). This varies from a normal web server in that the latter typically had the task of running scripts or programs using operations that were quite expensive for CPU load. Modern web servers do not have as much penalty but Java based solutions still have their advantages.
For test/dev environments, one does not need to have a web server in front. One can go directly to a WebSphere port (often port 9080) that provides a Java web implementation and not have the administrative burden of the care and feeding of a web server. On the other hand, IBM recommends using a web server for production (especialy for larger production loads). If one does use a web server, there are several that are supported. IBM HTTPS Server is a blue-washed version of Apache (there are some modules that are not supported but there are also lots of extra features to bind easily with WAS).
All the answers are good so let me give my cents ,
Websphere as other java applications, was made to work with dinamic contents .
apache or IHS that is apache IBM plugins can handle with all kinds of http/https requests , static , dinamic , proxy ,cache at the client tags, balance and so on ...
just using apache over java aplications is not the best ,
the best is allow apache handle all static downloads without call it from application server ,
like images and fixed htmls and left application server handle the just dinamic contents .
at this way we can optimize the environment , so development should create a pattern to dispose static and dinamic at different virtual direct like /jsp for dinamic and the rest as static , if not apache cache can be used instead for not overload the application server .
to make the story short , apache is so powerful ans can help a lot the application server sparing the work , a simple and effective usage is done to forward the port using default port 80/443 for http/https instead usual high ports on java application servers , make the apache deliver https is a best option too , instead left java application server care of it , so there is a lot of reasons to use Apache or IHS in front of application servers.