Rest Client Elasticsearch Host setup - rest

I am using Elasticsearch in one project an locally my client is located at localhost:9200, but when I am on dev environment my Elasticsearch client is at https://elasticsearch.eu:443/v1/elastic. When i am creating the Java client I use:
RestClient restClient =RestClient.builder( new HttpHost(Host, port)).build(). Which is the correct way to set the Host and port for the second URL, since we have an extra path?

In the version 7.17, according to Java Low Level REST Client - Initialization
RestClient restClient = RestClient.builder(
new HttpHost("localhost", 9200, "http"),
new HttpHost("localhost", 9201, "http")).build();

Related

Marklogic : JAVA API - Dynamic Database and REST Server

I am trying to see whether MarkLogic Java API can be used to create a content database and REST Server?
I went through te Java API but I dont see any reference.
Is it possible to create a REST Server through MarkLogic Java API?
I appreciate any links or pointers regarding this.
No, that's beyond the scope of the Java Client API. The Java Client API must connect to a REST Server after it's already created. You can, however, use the /rest-apis service on port 8002 via your favorite generic REST client API for Java. To see an example of how to do this with Apache HttpClient, see Bootstrapper.java. You can use it directly like the unit tests setup util TestServerBootstrapper.java does with this code:
Bootstrapper.main(new String[] {
"-configuser", username,
"-configpassword", password,
"-confighost", host,
"-restserver", "java-unittest",
"-restport", ""+port,
"-restdb", "java-unittest"});

Jboss fuse- running route with cxf endpoint in local camel context

I am working on a fuse project in Jbds. I am running a route as local camel context. It has cxf endpoint(soap), route started and started listening at /order/. If anyone has experience running camel context with cxf end point locally in the jbds, would you please let me know how to send soap message to this route which running in local camel context in jbds?
Are you looking to invoke webservice from java (client)?
you can use Service.create to create Service instances, the following code illustrates this process:
import java.net.URL;
import javax.xml.ws.Service;
URL wsdlURL = new URL("http://localhost/hello?wsdl");
QName SERVICE_NAME = new QName("http://apache.org/hello_world_soap_http", "SOAPService");
Service service = Service.create(wsdlURL, SERVICE_NAME);
Greeter client = service.getPort(Greeter.class);
For More info refer apache cxf documentation [1]
[1]http://cxf.apache.org/docs/how-do-i-develop-a-client.html
Please follow the steps to test the SOAP service exposed. The steps details are mentioned in the image link.Image for the steps to be taken.
See all the services exposed by CXF service (SOAP).
See the WSDL for the services exposed by CXF (SOAP).
Open SOAPUI and create new SOAP project.
Enter the details i.e WSDL URL in project detail.
The project will be displayed on the left-hand side.
Open the request in SOAPUI.
Fill the request and hit the green submit button.

Implementation of Proxy on Liberty for Java

I use "Liberty for Java" app and Statica service(Proxy) on Bluemix.
We set http.proxyHost/http.proxyPort/https.proxyHost/https.proxyPort as system properties in Java code every transactions.
for example:
URL url = new URL(xxx);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
........
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", port);
System.setProperty("https.proxyHost", host);
System.setProperty("https.proxyPort", port);
........
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
I have an issue that one transaction go from the app to a target server directly in spite of tens of thousands of transactions passed the proxy.
Question 1:
Do "Liberty for Java" app on Bluemix clear or update system properties, http.proxyHost/http.proxyPort/https.proxyHost/https.proxyPort?
I wonder "Liberty for Java" app updated with null to access outer servers in multi-thread environment.
Question 2:
Do "Liberty for Java" app on Bluemix communicate with outer servers?
I found the following log in Statica.
https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.agents.na.apm.ibmserviceengage.com
https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.gateway.prd.na.ca.ibmserviceengage.com
( I masked a part of URL.)
P.S. We will change java code with ProxySelector class or Proxy class.
Re #1: No.
Re #2: Potentially yes. In your case, it seems your app is bound with a Monitoring & Analytics service? If so, a data collector will be installed and will send collected data to remote servers.
What's the reason that you need to set the proxy system properties in your code? Is it because you want some connections to go through the proxy and others not?
If so, then the way you do this is not right because the system proxy setting is a global setting, not a thread-scoped setting. This means if one thread sets the proxy setting, all threads will then use that proxy; if one thread unsets it, all threads will then do direct connections. That may explain why you are intermittently seeing some direct connections. The right way is to use a http client lib that supports proxy as parameters, like https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/config/RequestConfig.Builder.html#setProxy%28org.apache.http.HttpHost%29
If you want all connections to go through the http proxy, then you should simply set the JAVA_OPTS environment variable to pass in those system properties, e.g., "-Dhttp.proxyHost=x.x.x.x -Dhttp.proxyPort=xx".

Java application getting projects and their associations from MS Project Server 2013

I want to use the REST api of a locally installed MS Project Server 2013 in order to get all projects and their associations(tasks, deliverables and resources) so that I will bind them with the business model of my custom J2ee application. So, I have 2 questions:
According to what I've read so far in MS Project Server documentation, I can use either ProjectData service or ProjectServer resource. What is considered more appropriate for my case?
Can anyone give me a simple example of getting projects and their associations using a Jersey client? Would something like the below be correct using the ProjectData service?
String url = "http://<pwa_site>/_api/ProjectData/$metadata";
Client client = Client.create();
WebResource webResource = client.resource(url);
ClientResponse response=webResource.accept("application/xml")
.get(ClientResponse.class);
String output = response.getEntity(String.class);
Any help would be appreciated.
ProjectData provides OData read-only access to the 38 entities for reporting. ProjectServer provides the main functionality of the Project Server Interface (PSI) for the primary entities.
For OData service, I use Apache Olingo library:
https://olingo.apache.org/doc/odata2/index.html

XDS.b testing with SoapUI

I have to implement a simple client to a XDS.b server (SubmitObjectRequest and RetrieveDocumentSetRequest operations), but I'm struggling to get even a simple example of use to work.
I've tried using Mirth Connect's Channel for XDS.b also, but with no use. I even tried to copy its SOAP envelope to use with SoapUI. Didn't work.
I'm using HIEOS deployed on Glassfish as my XDS.b server.
I'm lost and confused. Could anyone give me a guidance on how to make this work?
If the HIEOS is deployed correctly within the Glassfish the service endpoint provides a wsdl definition where the interface is specified. Check the Glassfish for the wsdl of the service.
http://localhost:8080/my-ws/simple?WSDL
Quelle: docs.oracle.com/cd/E18930_01/html/821-2418/gbiyw.html
The list of provided endpoints you can see here:
https://kenai.com/projects/hieos/pages/WebServices
So to retrieve the wsdl you should use for example:
http://localhost:8080/axis2/services/xdsrepositoryb?wsdl
which applies for the ProvideAndRegisterDocumentSet-b transaction of the XDS Repository actor.
You can use the WSDL definition to create a WS request using SOAP UI at first.
SOAP UI creates a request based upon the wsdl definition which can be used to
test a against your XDS repo.
When you know how a SOAP request must be constructed you can try it using Mirth or
create your own client using Apache CXF http://cxf.apache.org/ for example.
Or you use AXIS2 to create a client from the WSDL. Of course does Visual Studio and C# also offer mechanisms to create a WS client directly from a WSDL definition.