wood burning stoves 2.0*
The moose likes Web Services and the fly likes Need help connecting to WSDL for first time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Need help connecting to WSDL for first time" Watch "Need help connecting to WSDL for first time" New topic
Author

Need help connecting to WSDL for first time

Lori Burzynski
Greenhorn

Joined: Jan 29, 2009
Posts: 4

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.

Thanks in advance,
Lori
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Welcome to JavaRanch

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.

Some simple examples
GeoIP
StockQuote
Xslt2Xml
Lori Burzynski
Greenhorn

Joined: Jan 29, 2009
Posts: 4
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)?

Thanks again!
Lori
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
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.
Lori Burzynski
Greenhorn

Joined: Jan 29, 2009
Posts: 4
Thanks! I will update java6.

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.)

Thanks again for the help!
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Lori Burzynski wrote: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.


That is HTTP Basic Authentication. (Usually WS-Security is used with SOAP web services but it isn't universally supported by all SOAP stacks.)

That means you'll have to set the USERNAME_PROPERTY and PASSWORD_PROPERTY on the BindingProvider. See A little bit about Message Context in JAX-WS

Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
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.

Using JAX-WS-based Web Services with SSL: Set Up the Client Truststore and Keystore
Axis2: Accessing Web Service via SSL
Lori Burzynski
Greenhorn

Joined: Jan 29, 2009
Posts: 4

I am using Java 1.6 with update 5. When I check the "wsimport -version" it states that I am using "JAX-WS RI 2.1.1 in JDK 6". So why does it not list the options, such as "Xauthfile"?

(I even downloaded and installed the JAX-WS 2.1.1 again to make sure I had a complete version.)

Thanks in advance - again for any help!
Lori
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Lori Burzynski wrote:"JAX-WS RI 2.1.1 in JDK 6". So why does it not list the options, such as "Xauthfile"?


That parameter wasn't introduced until JAX-WS 2.1.3.

JAX-WS RI 2.1.5 download page
Running on JDK6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help connecting to WSDL for first time
 
Similar Threads
juddiv3 from wsdl to java?
generation of web service from stub java code
Faulty Web Services
Web service client
Accessing webservice using dynamic proxies