Table of Contents

JAX-WS web service in OEPE: HelloWorld

In this lab, we are going to create a simple JAX-WS web service in OEPE and deploy it to a running server.

Create Enterprise Application Project

An EAR (Enterprise Archive) is an archive file to pack an enterprise application project. It can contain either one or more web modules; one or more EJB modules; one or more client application modules; additional JAR files required by the application or any combination of them. It also contains one or more deployment descriptors which located in the META-INF folder.

If you want to pack the JAX-WS into a single EAR file, you firstly create an EAR project, for example as the following. Otherwise, you can ignore this section and move to next section, create a Web service project without selecting Add project to an EAR.

  1. File → New → Project → JavaEE → Enterprise Application Project. Click Next.
  2. Name the project as HelloEAR. Keep other defaul settings and click Finish.


Create Web Service

  1. File → New → Project → Oracle → WebLogic → Web services → Web Service Project. Click Next.


  2. Name the project as HelloWS. Select Add project to an EAR in the EAR membership and select HelloEAR.


  3. Click Finish.
  4. Open the HelloWS project → Java Resources → src, create new package (Right click, New → Package) named: hello.ws.wlsa. Click Finish.
  5. Select the package, create new WebLogic Web Service Class, named HelloJaxWs. Click Finish.
  6. Replace the generated hello function by the following codes:

    package hello.ws.wlsa;
     
    import javax.jws.WebMethod;
    import javax.jws.WebService;
     
    @WebService
    public class HelloJaxWs {
     
    	@WebMethod
    	public String hello(String name){
    		return "Hello "+name+" from JAX-WS service";
    	}
    }
  7. Save file.

Run the application

  1. Right click on the file, select Run → Run on Server (or using Alt+Shift+X, R).
  2. Select the exising Oracle WebLogic Server in the localhost (if you did not install this server, see the previous lab).


  3. Click Next → Finish. The server now starts your application and a WebLogic Test Client appears to allow you test your application


  4. login using the username and password you created during the configuration step
  5. click on test


  6. Type something in the input box and click invoke.



  7. You can see the request sent and the response

  8. You can check that the service's WSDL file at http://localhost:7001/HelloWS/HelloJaxWsService?WSDL
  9. Done.