Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI and JAX-WS

 
Chris Hannegan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tie a JNDI name to a Web Service?

I'm about 4 days in to Web Services using JAX-WS. I created a generic web service and have it deployed successfully on Sun App Server 9.
I created a generic client that calls my web service. I can run it and I get the expected results.

Two things I do not like (I dont like it because i dont understand it yet )
1. The wsdl attribute in the wsimport command. Here's my ANT snippet:
<wsimport sourcedestdir="${dir.wsimport}"
package="my.package.endpoint"
destdir="${dir.classes}"
wsdl="http://localhost:8080/foo/FooService?WSDL"
verbose="${true}">
</wsimport>

When I am building my client, I dont want to build it for DEV while pointing to one server, then build it again when i want to migrate my client to a TEST environment, then build it again when I want to migrate to my PRODUCTION environment.

2. My client java code looks like this:
public class FooClient {
//@WebServiceRef(wsdlLocation = "http://localhost:8080/foo/FooServic?wsdl")
static FooService service;

Again, I have my server name hard-coded. I dont want to recompile everytime I promote my code to a new environment.

According to documentation, you can tie a Web Service to a jndi name and i think i did that successfully. I just dont know how to call it.

@WebServiceRef API mentions that you can supply a JNDI name. However, I cant find any examples of this.

Can it be done?

While typing this...I was beginning to think it was impossible. Simply because you need to find the wsdl definition...and if you're using a jndi name...you still need to list the server that you are using.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic