This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes JAX WS URL mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAX WS URL mapping" Watch "JAX WS URL mapping" New topic
Author

JAX WS URL mapping

Rabi Kumar
Greenhorn

Joined: Aug 13, 2009
Posts: 6
I am trying to build a webservice using JAX-WS.

The endpoint URL of my service is like: http://host:port/contextroot/MyService

However, I would like to expose my service using the following URL: http://host:port/contextroot/services/MyService without changing the namespaces in WSDL.

Any help is appreciated.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Have you tried to modify the servlet-mapping in the web.xml deployment descriptor in the web service WAR (assuming you deploy the web service in a WAR)?
Best wishes!
Rabi Kumar
Greenhorn

Joined: Aug 13, 2009
Posts: 6
I deploy using EAR/war. However my web.xml is empty. I dont see my webservice defined as a servlet there.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Right, you do not need to define web services in the web.xml deployment descriptor, but if you have special requirements, like you seem to have, you can use the web.xml deployment descriptor.
Best wishes!
Rabi Kumar
Greenhorn

Joined: Aug 13, 2009
Posts: 6
I changed the contextroot in application.xml of EAR file as follows and I am able to achieve the desired behavior:

Old:
<contextroot>mycontextroot</contextroot>

New:
<contextroot>mycontextroot/services</contextroot>
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Thanks for sharing your solution!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JAX WS URL mapping