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

How to make the WSDL URL configurable?

 
Yogesh Gandhi
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I have a requirement where in client wants that the WSDL location should be configurable in the client's code.

I have generated clients code from the WSDL and it generates the client code something like the following

@WebServiceRef(wsdlLocation="http://localhost:8080/helloservice/hello?wsdl")
static HelloService service;

But the requirement is that this URL should be configurable and cannot be hard-coded.

Can you please suggest a way how can I do this?

Regards
Yogesh


 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setEndPointreference( ... ) will set the specific endpoint you want. new QName( ... ) will set the namespace and expose the path-to-service property. You may benefit by doing more in-depth reading of the Axis documentation.
 
Yogesh Gandhi
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here is the detail of my setup.

I generated stubs from WSDL using JDev 11g.

As specified earlier, the WSDL URL is being hard-coded in the generated stubs in the annotations as well. Due to this reason I am not able to set the WSDL path at run-time.

Here is the constructor of the class




This wsdlLocationURL is a private static URL member variable of the class, which we can definitely set at run time.

So, do you mean to say, that the URL given in the annotations as follows, doesn't impact it?



Someone is talking about Dynamic Proxy here. Do you have any clue about what it is ?


http://www.oracle.com/technetwork/articles/javaee/j2ee-ws-140408.html

 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The @WebServiceClient annotation sets only the default values. You can override these values at runtime. You can read information from a properties file and use that information as the input to the function calls I mentioned earlier to set the override values.

Dynamic proxy is something totally different. Don't get confused.
 
Yogesh Gandhi
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot man. I am glad to know that there WSDL URL can be set at runtime.

This answer of yours solves one of my biggest hurdles.

Thanks again.
 
Sudhindra Bhargav
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having the same question, could you point me to a proper example on how the wsdl location can be set at runtime.
Appreciate the help.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic