I created the java webhook in past for dialogflow where 1-1 mapping of intent used to be done. Now I am working with actions builder & not getting how to define and build the handlers using Java.
Before #ForIntent was used to map the intents with java methods. Now how should I map the methods with any scene or handlers.
At the moment there isn't a client library or a SDK to use in order to implement a webhook in Java for the Actions Builder.
You have to implement this manually, exposing and endpoint able to receive POST requests with a HandlerRequest object as input param, as specified in this json-schema
Once created your webhook, to select the handler to use you have to check the value under handler.name field of the request and invoke the right handler. To avoid hardcoded if/switch you could use a strategy pattern and reflection/bean loading to invoke the specific handler, using the value achieved by the field handler.name.
Related
I am trying to create a Rest route in Talen ESB open studio. I have an endpoint which has multiple methods inside.I access my API from Metadata. how can I reroute each endpoint according to its method. lets say endpoint is http://Example/api/version/Method/operation.
it has four methods Rawdata, balancing, customdata and final data. all these methods has multiple operations.
http://Example/api/version/Rawdata/getRawdata
http://Example/api/version/Rawdata/getdatafromfields
http://Example/api/version/balancing/getfiltereddata
How can I tell talend that when I call Rawdata in Soapui send this endpoint.
which components i can use or can Java code can do it?
Any help would be appreciated.
I am still learning Play framework for Java. I am trying to create a test case where I am mocking server. In there, I am defining url and response using RoutingDSL. However, I can't seem to find any way to access request headers (actually I am trying to see if client is sending proper cookies).
Here is the snippet of code:
server = Server.forRouter(20000, components ->
RoutingDsl.fromComponents(components)
.GET("/demo").routeTo(() ->
// Here I need something to get request headers or cookies
new Result(HttpStatus.SEE_OTHER_303)).build());
Solution:
After looking through the documentation (it was mentioned briefly here: https://www.playframework.com/documentation/2.6.x/JavaRoutingDsl):
Since you will be implementing actions, you may want to import the
static methods from Controller, which includes factory methods for
creating results, accessing the request, response and session.
Basically, idea was to use static methods from play.mvc.Controller class, where that information is held:
server = Server.forRouter(20000, components ->
RoutingDsl.fromComponents(components)
.GET("/demo").routeTo(() ->
doSomethingWithRequest(play.mvc.Controller.request())
new Result(HttpStatus.SEE_OTHER_303)).build());
I am an aspiring Android Developer, I have faced many issues in integrating my REST apis in Android. Existing solutions like Retrofit, volley are very generic.
I have been working on creating a generic framework for REST apis. Need help to complete it. I have configured components as follows:
Assumptions: Json data type as request body and json data type as request response
CentralCommandClass (activities will access this class to perform network operations with callback method as parameter)
API class extends IntentService (static functions for get, post, put etc to start service with different parameters)
MyHttpRequest (having execute method to open url connection and gets response from server)
My questions are as follows:
Does this approach has any downside?
There is a requirement to fire few requests only after one specific request has been fired, how do I handle this case?
I'm trying to determine the correct API calls on FacesContext to do the following when processing a backing bean action:
Within the action method construct a URL of dynamic parameters
Send the constructed URL to service
Parse the returned service response parameters
Continue with action method processing based on reponse string from request.
Any suggestions on the highlevel API calls for steps 2 and 3 to send me in the right direction would be very appreicated. Note, the service I'm calling is external to this application in a blackbox. Instructions are: send URL in specified format, parse response to see what happened.
This problem is not specific to JSF in particular, so you'll find nothing in JSF API. The standard Java API offers java.net.URL or, which allows more fine grained control, java.net.URLConnection to fire HTTP requests and obtain the response as an InputStream which you can then freely parse the usual Java way.
InputStream response = new URL("http://google.com").openStream();
// ...
Depending on the content type of the response, there may be 3rd party API's which ease the parsing. For example, Google Gson if it's JSON or Jsoup if it's HTML/XML.
I have created a request handler in Solr that uses dismax and limits my query to certain fields and adds boosts for relevancy on the "title" field.
This all works fine when I go directly to Solr using an http request in a browser. However my question is whether I can use the request handler if I am accessing Solr using SolrJ?
It would be better if I could control boosts and filters and so on in the request handler rather than having to make code changes but I can't see how to specify a request handler in the API.
Any ideas?
In the class SolrQuery, there is a method setRequestHandler that allows you to do that. You pass the name of the request handler as defined in solrconfig.xml (probably 'dismax').