One: Write interface program, calculate function class, have subtraction four methods
1 /**2 * 3 */4 PackageCom.hlcui.util;5 6 /**7 * @authorAdministrator Publish this class as a public interface8 */9 Public classCalculateutil {Ten /** One * Addition A * - * @paramx - * @paramy the * @return - */ - Public DoublePlusDoubleXDoubley) { - returnX +y; + } - + /** A * Subtraction at * - * @paramx - * @paramy - * @return - */ - Public DoubleMinus (DoubleXDoubley) { in returnX-y; - } to + /** - * Multiplication the * * * @paramx $ * @paramyPanax Notoginseng * @return - */ the Public DoubleMultiplyDoubleXDoubley) { + returnX *y; A } the + /**, the - * Division $ * $ * @paramx - * @paramy - * @return the */ - Public DoubleDivideDoubleXDoubley) {Wuyi returnX/y; the } -}
Second: Publish this class to provide an interface for others to call
Here I deploy it directly to the server to publish:
1:file--new--web Service
2: Configure interface information
3:next
Choose the interface method, start the service, etc., until finish.
Third, test whether the interface is published successfully
In the browser input: http://ip:port/projectName/services/class name? wsdl
For example: After my interface is published, enter in the browser address bar
http://localhost:8080/angular_study/services/CalculateUtil?wsdl
If the access succeeds, the following XML file information is rendered:
The interface was published successfully.
Four: Call the published interface, here can refer to the previous blog (call the Weather interface)
1: Save the WSDL file for the third step, and copy it to the SRC of the new project Angularclient
2: Right-click--web service--generate Client, the interface is as follows:
3: All the way next, to finish, will generate the client code under the Angularclient project.
4: Write the test code to call the interface.
WebService Publishing Interface