I placed a JAR file inside the ec2 instance and start it by using the following command
java -jar abc.java
I opened another ssh window and try to call the API endpoint, it fetched data successfully. However, when I am trying to call it from my local machine or Postman it gives me the error of Could not connect to the requested server host.
Following are my ec2 inbound rules. How can I call my rest endpoint. any help would be appriciated.
Related
As per my API testing, I had to first login to two ssh hosts through terminal(mac machine) then we use curl command for requests. I am asked to automate this using RestAssured.
To login hosts, I have used jcraft.jsch.JSch java library which i am able to access to hosts successfully but after this when I use below rest assured code, I am getting error "Connection refused"
Response response = RestAssured.given().header(<header>).body(<payload>).relaxedHTTPSValidation().when().post(<url>);
Is there any way to connect ssh hosts through Rest Assured framework or any other solution ? Please help.
We are using a secured Rest Service which generates a token based on a user name, password and referrer. It works fine when we run it from a Web project because it is clear the referrer is just the url of the web project. We need to run the code in a batch job and we are getting an invalid token error and we suspect the issue is with the referrer value. Since there is no url involved in running the batch job what should we use for the referrer value?
The code which calls the Rest Service is generated by the Rest Service WSDL and is located in an EJB module. The code is triggered by a Quartz timer.
EDIT:
I don't have control over how the request is sent. All I can do is use the method provided by the java client created from the service wsdl. I also have no control over how the token is created. The code which generates the token requires I pass it the referrer and it is used to generate the token. When the code is run in an app, then using the url of the app as the referrer works, the token is accepted. When the batch job runs there is no url, there is no browser involve, it is just code running on a server which executes the java method.
Doing some more research I found the code which generates the token will also accept the IP address which is what I think I have to do to use it in a batch job.
I have created a RESTful web service (using jersey in Eclipse) with Postgres database access. Both are running on my local machine. I have tested the service via the Postman client application sending some requests and getting responses as JSON to ensure that my server responds appropriately, all works fine. Now I have created a GUI (client application) using Swing for the management of the server (someone sits in front of it and manages the DB content). In addition, I want to do the following:
Start (not call) the RESTful web service from GUI (the person starts the GUI application to do his work, and with that the server starts, too, automatically). How can I do this is there any method I have to call?.
To query the server I have found these two methods:
RESTful Java client with Apache HttpClient and
RESTful Java client with Jersey client. Which of them is the better one?.
The overall structure of my communication processes using an Android client (in future) will be the following: Java client with GUI -- JSON --> RESTful web server <-- Android client
Use case: An Android client sends some data (text, pictures) in JSON format to the RESTful service which saves them in the Postgres DB. The Java client reads this data and displays them onto the GUI.
Mike, You will have to host your service on some server. Build a WAR file and deploy it on to a hosting server. Then you can call your API with the designated IP or masked name instead of localhost:8080 which I presume you are using. Also, I would recommend using a Jersy client.
I have .war on the server which contains servlets. When I send an HTTP request through the browser, I am able to connect and retrieve files. Now, I want to do this programmtically in Java. In order to connect, I am first sending a get request that contains the user name and the password. Now assuming that I will stay logged in, I am sending another get request with its parameters to get the file, but I am unable to retrieve the file. Is there any way to do this? Currently, I use HttpClient and HttpGet to connect and execute the get requests.
Eventually what I am trying to do is to have an application, deployed on a server call a servlet on the same server but under a .war (i.e. implemented as another application) and retrieve a file. I have tried to call the servlet directly but also I have been able to figure that out.
i am building a web service on eclipse using Apache AXIS 2 Webservice runtime using Apache Tomcat server (apache-tomcat-7.0.23) while running it on tomcat server it sucessfully shows that the web service is running...
But while creating Webservice client to test the web service and using the wsdl url in the server definition (http://localhost:9090/Axis2WSTest/services/Converter?wsdl), this gives below mentioned error and not letting me to create Webservice client:
The service definition selected is invalid
Can you please suggest me the error and possible solution for it?
The problem could be that your wsdl needs http authentication. I was getting the same error in eclipse, but it was because the server I was connecting to needed authentication and was returning a 401 error, so eclipse was saying it wasn't a wsdl. Eclipse doesn't seem to have the functionality to prompt for authentication, I was able to generate a client in netbeans using the same wsdl url because netbeans knows to ask for authentication.
Generate client from http authenticated wsdl
I was searching for the whole day for an answer for this,generally localhost will be added in your bypass proxy list and hence you will not encounter an error.
Go to windows--> preference-->general--> network-connection and see whether localhost is listed in your proxybypass list.If you are trying to access a external wsdl link and you under
some corporate network having proxy firewall you have to set http proxy/https proxy.
Is this how you are trying to generate client stub ?? If yes, just simply create a java project in eclipse, click on it, then press Ctrl+N, select web service client and enter your wsdl url. (make sure you have made sure you can access the wsdl url, by simply giving it in a browser).
Try replacing localhost with the actual IP address. I was facing the same problem and it worked for me this way
I had exactly same situation. For me the following worked:
I got the lead from rdp's response - "Try replacing localhost with the actual IP address. I was facing the same problem and it worked for me this way"
Using IP didn't work for me. What worked for me:
Instead of - http://servername/SomeWebService/Service.asmx?WSDL
putting FQDN for servername. For example -
http://servername.my.company.com/SomeWebService/Service.asmx?WSDL
I had the same issue and I was able to generate the stubs using soapUI. Please follow the this post. Which contains GENERATING CLIENT JAVA CODE FOR WSDL USING SOAP UI – AXIS2 WSDL2JAVA. Before that please download apache axis2 binary from here and extract it.