Sunday, June 10, 2007

Web Services in Oracle JDeveloper 11g

I have received a comment for my previous post - Web Services and Oracle TopLink, about if to try similar sample on Oracle JDeveloper 11g Technical Preview release. Yes, it is interesting, just because you can compare and evaluate new powerful features that will bring JDeveloper 11g Production release. I have tested Web Services development support in 11g using developed sample application - WSTopLink11.zip, this sample implements annotation only Web Service. I have used the same business logic as for previous one.

For persistence layer I'm using JPA entity with two Named Queries - Countries.findAll and Countries.findByName. When creating EJB Session Bean, Web Service Endpoint Interface is declared in the same way as in JDeveloper 10.1.3:


Generated interface for EJB Session Bean contains @WebService annotation, that in fact allows to use EJB Session Bean as Web Service directly:


Developed application structure in Application navigator window:


Oracle JDeveloper 11g provides embedded tool, that allows to test developed Web Service without deploying it to the server - just right click on EJB Session Bean and select - Test Web Service:


HTTP Analyzer window will be opened, where you can choose available operations to test, provide values for parameters and browse through generated result. Four views are provided - SOAP structure, HTTP Content, Hex Content and Raw Message. In our case, queryCountriesFindAll() generates similar result:


And, for queryCountriesByName(parameter) only result that is correct for specified parameter is shown:

6 comments:

Sanjay said...

Hi Andre,

I was trying to use your example on my local database with the same schema.

I created a "New" db connection called HR under Application Resources sub-tab.

How do i attach this to project, be'coz running as is i get an error:

Internal Exception: java.sql.SQLException: ORA-01005: null password given; logon denied

Error Code: 1005


Any help would be appreciated.

Andrejus Baranovskis said...

Hi,

If you right click on Model project and choose Project Properties, you will see in EJB Module section that jdbc/HrDS data-source is used by application.

You can define data-source in Tools -> Embedded OC4J Server Preferences -> Current Workspace -> Data Sources.

Regards,
Andrejus

Sanjay said...

Thanks for the solution. It worked for me in embedded as well as in standalone OC4J servers.

One problem I face is the repeater tags in Response of this WebService are return..return.

In an application I am trying to retrieve data from this WebService, the word return is a reserved word and so cannot be used.

Is there a way that this repeater tag can be changed as myreturn..myreturn

Thanks in advance.

Andrejus Baranovskis said...

Hi,

Not sure about this.

Regards,
Andrejus

Sanjay said...

Found the solution:
At the Method level (wherever your @WebService annotation is) if you use the annotation @WebResult(name = "myreturn"), then I was able to change the repeater tags to myreturn.

Andrejus Baranovskis said...

Thanks for posting solution Sanjay.

Regards,
Andrejus