I have a task to create Java code to connect and retrieve results using a WSDL on a remote server. I hava a valid URL, username and password.
I am new to the world of web services. I understand the theory. I am unsure of the implementation. I am using Java 6, Tomcat 5.5, Axis 2, Eclipse 3.4.1, and MyEclipse 5.
I have successfully used the MyEclipse Web Services Explorer to connect to the service and obtain results (By doing this I learned that the service is valid, authentication worked and it is not blocked.)
I have read a mountain of information and tried a few different things. The latest and most promising test was using WSDL2Java. (Eclipse Plugin) It generated 12000+ lines of code that was buggy. I added in the jars to remove the errors, but I am stuck on where to go from here.
Any assistance would be appreciated. I am so stuck. If you need more input from me, just ask, I will gladly provide it.
Given that you are using Java 6 there shouldn't be a need to use Axis2. You could simply use Java API for XML Web Services the (JAX-WS) wsimport to generate a consumer web service proxy for you. To keep things simple I'd start with a simple console/command line program to figure out how the proxy works - the proxy generated can be used in a servlet/JSP.
Thanks for the information! I have an error using wsimport. It says:
[ERROR] Failed to read the WSDL document: <URL>, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>. unknown location
I know that it is a valid WSDL. Could it be because of the authentication parameters? Also, any idea why my version of wsimport not list the -Xauthfile option (among others)?
Lori Burzynski wrote:I know that it is a valid WSDL.
If all else fails use a browser to save the WSDL as a file and then run wsimport against the file.
As to the "authentication" - a username and password can be used in a variety of ways - so far you haven't mentioned the form of authentication that you are using.
Lori Burzynski wrote:Also, any idea why my version of wsimport not list the -Xauthfile option (among others)?
Early JDK 1.6 distributed with JAX-WS 2.0. Starting with update 4 it distributed with JAX-WS 2.1. The link refers to JAX-WS 2.1.5.
Peer Reynders wrote:As to the "authentication" - a username and password can be used in a variety of ways - so far you haven't mentioned the form of authentication that you are using.
I really do not know what "form" of authentication is used. It is handled by the remote server. If I open the file in the browser I am prompted for username/password. I am also prompted for the username/password in the web services explorer. (By the way, the URL is https.)
Lori Burzynski wrote:(By the way, the URL is https.)
In that case you also need to set up a client trust store that contains the server's certificate - otherwise the Java client will refuse to establish a secure connection with the server. Some browser's like FireFox let you export the server's certifcate.