• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Need help connecting to WSDL for first time

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic