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.
teaching_assistant/web_services/weblogic_complex_type_v12.txt · Last modified: 2021/08/31 15:39 by Nour
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0