Sunday, July 4, 2010

Creating Webservice from WSDL and Testing in HTTP Analyzer - Part 3 of Creating your own Webservices in JDeveloper11g


As you can see in my last 2 posts i have created a XML Schema, WSDL document and we have defined the operations that our webservice will perform,

Now its time to implement the business logic in the webservice.

Creating a Webservice from WSDL
  • Right click the WSDL document that we have created and choose Generate Webservice. Follow the slides for basic webservice setups with No Policies defined.

  • Press Finish and wait for Jdeveloper to finish his magical things.

  • Now you can see Jdeveloper generated lot of Java classes and code in automatically, as you can see as well that file create which provides the basic implementation of the webservice and Jdeveloper created all related Java classes on the types we have defined in the XML Schema so we can use them as a Java objects.

Retrieving Status from Oracle table via JDBC call
  • Next it to retrieve the status of credit cards from database table for this we will use a simple JDBC statement to retrieve the values from the table but for his we have to add a JDBC library to our project
  • To add a JDBC driver into your Project, Right click the project choose Project Properties go to Libraries and Classpath press Add Library and choose Oracle JDBC and press OK

  • Now for code separation we will add the JDBC realated code to another Java Class, Right click the packages.types i.e baigsorcl.types package in application navigator and choose New, Select Java Class and enter name "OraJdbc" press OK
  • Copy and paste the following code to the OraJdbc class (the purpose of this class is to create a connection via JDBC to oracle database and execute a query and return the status of credit card) and compile it (right click choose Make)

package baigsorcl.types;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class OraJdbc {
    public OraJdbc() {
    public String getCreditCardSatus(int ccNo) throws SQLException {
      //Return variable
      String result = "INVALID";
      //Connecting to DB
      Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");
      //executing query
      Statement stmt = conn.createStatement();
      ResultSet rset = stmt.executeQuery 
            ("SELECT creditcard_status FROM CreditStatus where Creditcard_number = " + ccNo );
      //retreiving resultset
      while ( ())
      result = rset.getString(1).toString();
      return result;

  • Now call method of OraJdbc class in the myPortImpl class, Your getCreditCardStatus method should look like this

      public CreditCardResponse getCreditCardStatus(CreditCardRequest part) {
        CreditCardResponse response = new CreditCardResponse();
        OraJdbc callDb = new OraJdbc();
        String result = "INVALID";

        try {
          result =  callDb.getCreditCardSatus(part.getCcNumber().intValue());
        } catch (SQLException e) {
        return response;

Thats all you are ready to Test your service.

Testing the Webservice
  • Right click the and choose Test Webserivce, an integrated WLS will start and opens a HTTP Analyzer tool which is available within JDeveloper to test the webservices.

  • Enter the Credit Card number 1234 and press Submit Request, as you can see the result on the right side is appearing as VALID (because in our table this number has a as VALID status)

  • Enter 9999 and you would see the result INVALID

Click the HTTP Context tab at the bottom to see the payload info in HTTP Format

Hope you have found the series useful, feel free to comments and ask questions i am always available to response your queries.

Download the complete workspace of Part 1,2 and 3

Happy JDeveloping,


  1. i get invalid for everything

    and some erros:
    WSSERVLET11: failed to parse runtime descriptor: invalid value for attribute "implementation" of element "endpoint" in runtime descriptor (line 3) invalid value for attribute "implementation" of element "endpoint" in runtime descriptor (line 3)
    <08.07.2010 21:55 Uhr GMT+01:00> <User defined listener failed: WSSERVLET11: failed to parse runtime descriptor: invalid value for attribute "implementation" of element "endpoint" in runtime descriptor (line 3). WSSERVLET11: failed to parse runtime descriptor: invalid value for attribute "implementation" of element "endpoint" in runtime descriptor (line 3)
    at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(
    Truncated. see log file for complete stacktrace

    Caused By: invalid value for attribute "implementation" of element "endpoint" in runtime descriptor (line 3)
    Truncated. see log file for complete stacktrace

  2. Download the sample workspace check if its working

  3. hi,

    i am getting "two ports in the GetCustomers(webservicedescriptionbean)has the same name " while running the webservice implementation through jdeveloper 11g.

    Please help me on this.

    1. Hi,

      Sorry i don't understand what you mean.


  4. Thank you for this tutorial. It's nice and simple. Can you write another tutorial, how with PL/SQL connect to WebService, get Resresponse and insert into table? Please.

    1. Hi,

      If you are talking in ADF context then you can expose any Java method and expose it as Service check this link for more info