Step 2: Implement Synchronous Communication

In this step you will create the web service and you will add a synchronous method to this web service. Remember that when a client invokes a synchronous method, it is blocked from continuing its own processes until it receives the return value from the web service.

The tasks in this step are:


Create the Web Service

  1. Right-click MyJWSProject in the Application tab, and select New-->Web Service.
  2. In the New File dialog, ensure that Web Service is selected and enter the file name Hello.jws.

  3. Click Create.

Add a Method

  1. Right-click the web service in the main area and select Add Method.

  2. The method newMethod1 appears. Rename this method hello_sync. If you step off the method before you have finished renaming it, right-click the method and select Rename.
  3. Click the hello_synch method to go to Source View and modify the method as shown in red below:
        /**
         * @common:operation
         */
        public String hello_synch(String name)
        {
            return "Hello, " + name + "!";
        }

You have now created a web service with the method hello_synch. This method is considered synchronous because when the method is invoked, the invoking client has to wait until the method has finished processing and returns a String result. A synchronous method that returns a result to the invoking client is depicted in Design View as a straight blue arrow pointing to the right, with white arrows in both directions on top of the blue arrow.

Test the Web Service

Next you will test the web service to examine its behavior.

  1. Click the Start button, shown below:

  2. When the Workshop Test Browser launches, in the Name field, enter [your_name] and click hello.

  3. Examine the result returned by the hello_synch method. Scroll down to the Service Response section and notice that the method returned Hello, [your_name]!

  4. Return to WebLogic Workshop and press the Stop button to close the Test Browser.

Click one of the following arrows to navigate through the tutorial: