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.
File → New → other → Oracle → Weblogic → Web services → Web service project.
Name it as RectangleService. Keep the defaut configuration and Finish.
Create a new package in the Java Resources\src folder: New → Package and name it as rec.ws.wlsa.
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;
}
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.
Name it as RectangleComputation and click Finish.
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;
}
Save file. Right click on the RectangleComputation.java file → Run As → Run on Server (or Alt+Shift+X,R).
Select the runing WebLogic Server → Next → Finish.
A Web Service client interface provided by Oracle Weblogic is opened. Click on Test.
Input the rectangle's width and length
You will get the result like the following:
Done.
Back to top