Jersey REST web service find source code from URL - java

I have a prebuild framework where web services are already implemented using the Jersey framework.
I have a list of web services URLs and access to jar library where there is a complete set of jars(200+) including the web-service jars.
I need to find the extract class and method name which is invoked when a web-service url is invoked.
E.g webserice url: https://myserver/resources/v1/foo/bar
How to find which class(along with package name) and method is invoked when above url is hit.
I have tried finding keywords "foo" "foo/bar" "bar" using find in files options of notepad++. But it gives a big list of jars and not able to drill down the exact class and method name.

Related

Unable to test web service deployed on server

I have developed and published a Java web service on Glassfish server using Netbeans. I can test and use the wsdl file properly using my local application. When I deployed the war file on the server (temporarily I am using jelastic.com as my server), I can access the wsdl file using the URL
http://fesdvi.jelastic.servint.net/FESWebService/Diagnose?WSDL
But cannot test the web service using url
http://fesdvi.jelastic.servint.net/FESWebService/Diagnose?Tester
It gives me following error message
Error generating artifacts for the following WSDL (removed http:// as cannot post more than 2 links) fesdvi.jelastic.servint.net/FESWebService/Diagnose?WSDL
Possible causes can be invoking https when the application is not configured for security
PS: I am not using secured http.
Please help me to sort out this problem.
Following is the extract from the server-instance.log
[ERROR] Connection refused
Failed to read the WSDL document: because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not .
Could not find wsdl:service in the provided WSDL(s):
At least one WSDL with at least one service definition needs to be provided.|#]
Failed to parse the WSDL.|#]
wsimport failed|#]
Moreover I am trying to find the wsdl on the server but I am not able to find, I am still exploring the application deployment structure in jelastic..
It looks like the root cause of the issue is wrong endpoints settings,
since you have uploaded your project with local machine settings.
It is possible to see list of all Web Service endpoints at the Admin Console. After you have logged to it, look at tree in the left, find item "Applications" expand it and click on your WebApplication. You will see the table, in action column you will find "View Endpoint" links (They should contain the URL of your environment and correct ports).
Also, I think that the Eclipse plugin from Jelastic (http://docs.jelastic.com/eclipse-plugin-user-manual) will help you to solve this issues.
P.S. If this will not help, you should to contact with your Hosting Provider Support and ask them about the help.

Using RestTemplate with local json file

Background
I'm writing a web service that makes calls to an external api. This api has not yet been put into production. As such, when I make a call to my web service in my dev environment, I want to stub out the responses that it returns. Note: this is not a unit testing question.
My Solution So Far
The api calls are made using RestTemplate from the lovely Spring people, the url of which is held in application.properties. This has allowed me to set different urls for different environments using Active Profiles. So, for example, application-dev.properties holds a different url.
The dev url is ideally a pointer to a json file under resources/.
My Issue
I can't seem to get RestTemplate to pick up the local json file. The url I'm using is:
url = "file://staticJson.json"
However that comes up with a
Object of class [sun.net.www.protocol.ftp.FtpURLConnection] must be an instance of class java.net.HttpURLConnection
And now I'm unsure of how to proceed, or if this is even possible without extending RestTemplate.
Any directions to try or solutions would be fantastic.
If any more information is required I'll do my best to provide it asap.

Access Web service from java when wsdl file is known

I am trying to access a web service in the remote system by using java code. I take the WSDL URL from the XMethods registry and download the WSDL file from that location. I parse the WSDL file and display the list of operations and their Input and Output parameters and type. I will get the Input from the user according to the Information I got from the WSDL file. Now What I am need is I need to display the user the corresponding output from the Webservice. For this what is the easiest method to consume the Webservice. I dont have any Idea. Please anyone can help me??? Thanks in advance.
you can user axis2 jar framework to consume the webservice. Axis2 jar's generate the dependency files to consume the web service. Use this link to create client files.
http://javapapers.com/web-service/axis2-web-service-using-eclipse/

Using a Web-Service with Java Servlets

I'm trying to develop a very simple Java web application using JSP and Servlets.
1) There is a textbox and a submit button on the page,
2) The user enters his name, say John, to the textbox and clicks the button,
3) The string is forwarded to my servlet,
4) At the doPost method of my servlet, I access the posted string variable,
5) The web service I'll use has a sayHello method that takes an argument and returns "Hello " concatenated with the argument,
6) So, I call the sayHello method of the web-service, get the returned variable and forward this to a JSP, which basically writes Hello John.
I'm familiar with the JSP and Servlet thing, but I don't know how to use an already existing web-service, or how to make use of a functionality that is already implemented in that web-service.
All I have is the name of the method, sayHello, the URL of the web service, http://example.com/hello_service and a link to a wsdl file which contains xml-like code that I do not know how to make use of.
My question is, how do I make use of that web service, or how do I call a method inside a servlet?
Thanks in advance.
I'm using Eclipse for JavaEE Developers. How do I generate a client automatically?
Drop the WSDL file in your dynamic web project (or create a new project for it), rightclick it, choose Web Services > Generate Client, complete the wizard with default settings. A new package will be created where the generated WSDL client code is been placed. One of those classes have a ServiceLocator in the classname.
In the servlet, you need to instantiate the ServiceLocator class, get the SOAP service from it and then invoke the desired methods on it. Further detail can't be given since the WSDL is unknown.
See also:
Eclipse - Creating Web Service Client (Eclipse's own tutorial does it bit differently)
You can use "wsimport" from jax-ws to generate a client jar for the web-service. Then, including the client jar in your classpath, you can call the web service just like you would call any regular method.
you have to create client stubs which will be part of your code project (which has the servlet). The WSDL defines how to generate these stubs. The you can call the methods in the stub from your servlet. You can use a variety of tools to generate these stubs, Axis2 is one of the most widely used.
Here is the apache Axis2 documentation which tell you how to do it.
This stub will have the methods that the wsdl has defined. You will basically call these methods and internally the stub implementation (autogenerated from wsdl by axis2) will create the SOAP request based on the arguments you pass to the method. Then it will send this request over HTTP or HTTPS to the webservice URL. You will feel like you're calling code that resides on your machine, but internally it makes the call to remote webservice.

Get the file list in the WebServer from the appserver

Hi all
Is there any methods to fetch the File List in the Web server from the Application Server using JAVA?
i am finding something like new file ("/webserver_context_root/folder/") method that using the relative path to get the web server's resources from the app server...
PS : The reverse proxy has been set between the web and application servers.
Any ideas?
The HTTP protocol provides no standard way to list a "folder". Indeed, the HTTP and URI / URL specs don't even recognize "folder" as a concept.
If the folder notion is meaningful for your website then there are two approaches that could work:
Many webservers can be configured to produce a listing (e.g. in HTML) for a URL that corresponds to a folder in the webservers content space. (This is usually turned off for security reasons.) You can "scrape" this HTML to extract the list of names of things in the folder.
You could implement a RESTful service to return a list of the "files" in a "folder" as (say) JSON or XML.
Note however, that both approaches will be specific to that website. They won't work for arbitrary websites. I'm also assuming that the "application server" accesses the "web server" using HTTP. If it can access it some other way, there may be other solutions.

Categories

Resources