title: Testing web service in JDeveloper 12c
body: <p>I have made very simple web service using <strong>JDeveloper 12c</strong>.
  I have a class named Person:</p>
  
  <pre><code>package testapp;
  import javax.xml.bind.annotation.XmlRootElement;
  @XmlRootElement
  public class Person {
      private String firstname;
      private String lastname;    
      public Person() {super();}    
      public Person(String firstname, String lastname) this.firstname=firstname;this.lastname=lastname;}
      public void setFirstname(String firstname) {this.firstname = firstname;}
      public String getFirstname() {return firstname;}
      public void setLastname(String lastname) {this.lastname = lastname;}
      public String getLastname() {return lastname;}
  }
  </code></pre>
  
  <p>...and a class PersonService:</p>
  
  <pre><code>package testapp;
  import java.util.ArrayList;
  import java.util.List;
  import java.sql.*;
  public class PersonService {
      private List&lt;Person&gt; persons;
      public PersonService() {
          super();
          this.persons = new ArrayList&lt;Person&gt;();
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
          } catch (ClassNotFoundException e) {
              System.out.println("ERROR: Cannot find Oracle driver!");
              e.printStackTrace();
              return;
          }
          System.out.println("STATUS: Oracle JDBC Driver Registered!");
          Connection connection = null;
          PreparedStatement preparedStatement = null;
          try {
              connection = DriverManager.getConnection(/* my database connection parameters */);
          } catch (SQLException e) {
              System.out.println("ERROR: Connection Failed! Check output console!");
              e.printStackTrace();
              return;
          }
          if (connection != null) {
              System.out.println("STATUS: Connection established.");
          } else {
              System.out.println("ERROR: Failed to establish connection!");
          }
          try {
              String selectSQL = "/* select first and last name from database */";
              preparedStatement = connection.prepareStatement(selectSQL);
              ResultSet rs = preparedStatement.executeQuery();
              while (rs.next()) {
                  this.persons.add(/* Get data from database and make new Person */);
              }
          } catch (SQLException e) {
              System.out.println(e.getMessage());
          } finally {
              try {
                  if (preparedStatement != null) {
                      preparedStatement.close();
                  }
                  if (connection != null) {
                      connection.close();
                  }
              } catch (Exception e) {
                  System.out.println("ERROR: Something is seriously wrong...");
              }
          }
      }
      public List&lt;Person&gt; getPersons() {return this.persons;}
      public void addPerson(String firstname, String lastname) {
          if (firstname != null &amp;&amp; lastname != null) {
              System.out.println("Hello, "+firstname+" "+lastname+"!");
          } else {
              System.out.println("ERROR: First name or last name is null!");
          }
      }
  }
  </code></pre>
  
  <p>I have followed <a href="http://multikoop.blogspot.com/2013/08/jdeveloper-12c-create-restful-service.html" rel="nofollow noreferrer">this tutorial</a> to make a web service and to test it. I chose application/xml and application/json type of parameters. Finally, my addPerson method looks like this:</p>
  
  <pre><code>@POST
  @Consumes(value = { "application/json", "application/xml" })
  @Path("/person")
  public void addPerson(@FormParam("firstname") String firstname, @FormParam("lastname") String lastname) {
      if ((firstname != null) &amp;&amp; (lastname != null)) {
          System.out.println("Hello, "+firstname+" "+lastname+"!");
      } else {
          System.out.println("ERROR: First name or last name is null!");
      }
  }
  </code></pre>
  
  <p>I'm able to test my GET method (getPersons), and I get a nice looking response. But I have no idea how to test POST method (addPerson), i.e. I don't know how to supply the parameters. Here's the screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/IhjbO.jpg" alt="Screenshot"></p>
  
  <p>I tried clicking on the green plus sign (Add header), then changing the header names to "firstname" and "lastname" and setting some values, but when I click "Send request", an error message appears (first name or last name is null).</p>
  
  <p>What is the right way to enter some input parameters?</p>