Publishing Java based WebServices using JAX-WS in JDeveloper 11g

Lucas Jellema 3

Recently I have been doing quite some work with WebServices – calling them and implementing them, from and in both PL/SQL and Java. And in conjunction with BPEL and ESB. Today, I did some quick tests using JDeveloper 11g (TP4) and more specifically JAX-WS. It turns out to be very simple to publish (and test) a Java based WebService – a matter of minutes.

This article will very briefly demonstrate how to get a WebService up and running, based on a simple Java Class.....



1. create new JDeveloper Application

2. create empty project – in my case JAXWSQuizMaster

3. Add a number of libraries to the project


4. Implement Java Class that we want to publish as WebService

For example:

package nl.amis.quiz;

public class QuizMasterService {

public QuizQuestion getOneQuizQuestion(String topic) {
QuizQuestion q = new QuizQuestion();
q.setQuestion("What is the capital of France?");
return q;


package nl.amis.quiz;

public class QuizQuestion {
private String question;
private String answer;
private String hint;
private int difficulty;

public void setQuestion(String question) {
this.question = question;

public String getQuestion() {
return question;

public void setAnswer(String answer) {
this.answer = answer;

public String getAnswer() {
return answer;

public void setHint(String hint) {
this.hint = hint;

public String getHint() {
return hint;

public void setDifficulty(int difficulty) {
this.difficulty = difficulty;

public int getDifficulty() {
return difficulty;


5. Add JAX-WS annotations to the Java Class

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(name = "QuizMaster", serviceName = "QuizMasterService", portName = "QuizMasterPort")
public class QuizMasterService {

public QuizQuestion getOneQuizQuestion(String topic) {


Note: after adding these annotations, we can look at the WSDL that will be dynamically generated for this class by selecting Show WSDL from the right mouse button menu:

I just learned a better way of getting up the web.xml – please ignore step 6A that I first included in this article.

6. Create WebService for the QuizMasterService:

From the New Gallery, Business Tier – Web Services select the option Java Web Service. In the wizard that is started, select the QuizMasterService class as the Component to publish. Accept all defaults in the remainder of the wizard, then press Finish. When done, the web.xml will have been generated:



6A. Note: this was orginally in this article. While not necessarily wrong, it describes an inferior way of creating the web.xml file!

Configure a servlet in the web.xml file for the Port

Go to the New Gallery, From the Web Tier node, Servlets category choose HttpServlet. Choose Servlet 2.5.

Press Next

Press Finish.

Now we need to slightly edit the web.xml file, as we do not really want to map to a class called QuizMasterServiceServlet. Just strip the Servlet from the class name. The web.xml should now contain:


 Feel free to delete the class QuizMasterServiceServlet that this wizard has generated.

7. Test (or Run) WebService

On the RMB menu on QuizMasterService class, select the option Test Web Service:

The WebService is deployed – its WSDL can for example be accessed from a browser at in this case: http://localhost:8988/JAXWS-JAXWSQuizMaster-context-root/quizmasterservice?WSDL .

The JDeveloper 11g WebService Tester is displayed:

Enter the value for the input parameter (not that it makes any difference, but with a more advanced service implementation – that is: better fleshed out getOneQuizQuestion() method in the QuizMasterService class – it would make a difference) and press the Send Request button.

The WebService is now invoked and the Java Class can do its work. The result:


Note: the WebService can also be tested by accessing it from a browser at the ‘servlet url’ (in this case http://localhost:8988/JAXWS-JAXWSQuizMaster-context-root/quizmasterservice). OC4J will turn this request over to the built in WebService invocation facility that shows up like this:


And show the reply like this:


We have seen how using a few JAX-WS annotations allows us to very rapidly turn a Java Class into a WebService. JDeveloper 11g has support for JAX-WS and for locally deploying and tesing the WebService (as well as dynamically generating the WSDL). JAX-WS compliant JEE containers such as WebLogic 10.3 and OC4J 11g can be used to actually deploy and run this WebService.

3 thoughts on “Publishing Java based WebServices using JAX-WS in JDeveloper 11g

  1. Hi,
    Do you know how to call this JAX-WS from ADF context by storing the same in connection.xml?
    Please provide the example, if you have?

  2. Hi,

    Did you not by any change make webservice from a pl/sql package? Using the built-in generators I can generate jax-rpc services which cannot be deployed due to some mystic serialization symbol not found on Sun Application Server. I was looking around to see if somebody knows a way to generate jax-ws services directly from pl/sql.



  3. Hi Lucas,

    nice article, I think this should work in 10.1.3 too , I already did this with a adobe flex / blazeds example with jdev ( )

    By the way. Rest support is also very easy
    add @Deployment(restSupport = true) to the code and you have a rest web service too.

    @WebService(name = “QuizMaster”, serviceName = “QuizMasterService”, portName = “QuizMasterPort”)
    @Deployment(restSupport = true)
    public class QuizMasterService {

    and you can test this rest ws with the following url /JAXWS-JAXWSQuizMaster-context-root/getOneQuizQuestion?topic=geography

Comments are closed.

Next Post

Latest Oracle Pricing List - new suites and options give interesting insights

Oracle recently published the most recent version of their global price list. I am not sure how it translates to local transactions (for example if and how the currency exchange rates are applied). And I cannot say I understand all the options listed. But some of the entries are interesting […]
%d bloggers like this: