invoke a RESTful service from IS

Hi,

I want to invoke a RESTful web service which of the ElasticSearch server from Integration server.

If I execute the below CURL commands on the Elastic search server console, it works.

If I execute curl -XPUT ‘172.29.223.226:9200/twitter/tweet/1?pretty’ -d’

{
“user” : “kimchy2”,
“post_date” : “2009-11-15T14:12:12”,
“message” : “trying out Elasticsearch2”
}’

I get output as

{
“_index” : “twitter”,
“_type” : “tweet”,
“_id” : “1”,
“_version” : 3,
“_shards” : {
“total” : 2,
“successful” : 1,
“failed” : 0
},
“created” : false
}

Also curl -XGET ‘172.29.223.226:9200/twitter/_search?q=user:kimchy&pretty’ shows correct output.

How to invoke these APIs from Integration Server?
Will http client invocations such as http://172.29.223.226:9200/twitter/_search?q=user:kimchy&pretty with GET method solve the purpose?

Kindly advice how to invoke the get and put restful services on ElasticSearch server?

You can use “pub.client:http” to perform PUTs and GETs to/from Elastic Search.

I have attached an image which gives you a clear idea on how to do PUT. If you are interested in the response after the PUT then use “pub.string:bytesToString” to convert the bytes under body (body/bytes) what comes back from pub.client:http service.

GET is fairly straight forward:

  1. Map your request URL as-is to “url” input of pub.client:http service.
  2. Set “method” to “GET”
  3. DONE
1 Like

Thanks Prasad.

I tried both get and put to elasticSearch server via IS as you suggested.

But I get 403 forbidden access error from IS for both methods.

From Elastic Search console, it executes the commands.

Is there any setting to be done on ElasticSearch side to enable IS to put and get via http requests?

Regards,
Revathi

You do not need to do any setting on Elastic Search side to perform PUTs and GETs. Are you passing in the authentication details that are required to access elastic search in your pub.client:http service?

I have attached a new image that shows you where to set the authentication details in pub.client:http.

1 Like

Hi Pramod,

I gave basic authentication parameters with user I had created to run te elasticsearch server with the password.
But still I get 403 error.
I converted the bytes to string and got the below string.

Access control configuration prevents your request from being allowed at this time.

Please verify your proxy-settings. Should point at http:/proxy-pac-anycast.ericsson.se for automatic configuration script(PAC)

If you still think this is incorrect, support mail is <a href="mailto:tools.support@ericsson.se?subject=CacheErrorInfo%20-%20ERR_ACCESS_DENIED

I will reach out to my network guy to dig into it.

Complete response from bytes to string :

ERROR: The requested URL could not be retrieved

Revathi, it looks like your IS is not able to reach the elastic search URL. Is it on the internet or outside your network? Does it require to configure a proxy?

Actually IS and Elasticsearch servers are installed on same machine.
Because this is the dev environment.
When I tweak the URL to have localhost instead of IP of the machine, I get connection refused with ACL and invocation related classes.

com.wm.app.b2b.server.ServiceException: java.net.ConnectException: Connection refused
at pub.clientimpl.http(clientimpl.java:996)
at sun.reflect.GeneratedMethodAccessor1598.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:406)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:649)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:39)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:49)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:303)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:34)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:377)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:548)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:385)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:238)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:221)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:254)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:520)

Check if there are any “Proxy” servers configured on your Dev environment. If you see any, disable them temporarily and try to call your service again with “IP Address” instead of “localhost”
Capture.PNG

Ok, checking with the network guy.
Will let you know once it works.

Hi,

if proxies are configured, you might want to add your IP adress to the proxy bypass list.

Regards,
Holger