Complex type messages

In this lab, we will create a simple service that manipulates the SOAP messages with complex type variables. We use an example about the perimeter and square computation of a rectangle. By the same way, you can deploy other complicated web services.

  1. File → New → other → Oracle → Weblogic → Web services → Web service project.
  2. Name it as RectangleService. Keep the defaut configuration and Finish.


  3. Create a new package in the Java Resources\src folder: New → Package and name it as rec.ws.wlsa.
  4. In side this package, create a Java class named Rectangle. Insert the following codes to this class:

    package rec.ws.wlsa;
     
    public class Rectangle {
     
    	public int perimeter;
    	public int square;
     
    }
  5. Create a WebLogic Web Service under the rec.ws.wlsa package: Right click on the package → New → other → Oracle → Weblogic → Web services → WebLogic Web Service.
  6. Name it as RectangleComputation and click Finish.


  7. Replace the hello method by the following code:

    	@WebMethod
    	public Rectangle compute(@WebParam(name="width") int w, @WebParam(name="length") int l) {
    		Rectangle r = new Rectangle();
    		r.perimeter = w*l;
    		r.square = 2*(w+l);
    		return r;
    	}
  8. Save file. Right click on the RectangleComputation.java file → Run As → Run on Server (or Alt+Shift+X,R).
  9. Select the runing WebLogic Server → Next → Finish.
  10. A Web Service client interface provided by Oracle Weblogic is opened. Click on Test.
  11. Input the rectangle's width and length


  12. You will get the result like the following:


  13. Done.