In the previous post we created a simple Web Service in Java. Now we’ll build on it, by providing more methods with standard argument and return types.
- String
- Number
- Boolean
- Array
- Variable arguments
Let’s recall the Web Service with a single available operation.
@WebService @SOAPBinding(style=Style.RPC) public interface SimpleService { @WebMethod String sayHello(); }
Strings
Apart from sayHello, we would like a new operation that says hello to a given name.
@WebService @SOAPBinding(style=Style.RPC) public interface SimpleService { @WebMethod String sayHello(); @WebMethod String sayHelloTo(String name); }
Let’s implement it.
@WebService(endpointInterface="simple.SimpleService") public class SimpleServiceImpl implements SimpleService { public String sayHello() { return "Hello from Web Services!"; } public String sayHelloTo(String name) { return String.format("Hello %s!", name); } }
If we publish the Web Service and access its WSDL, we’ll notice some new lines.
... <message name="sayHelloTo"> <part name="arg0" type="xsd:string"/> </message> ...
Booleans and Numbers
Here is…
View original post 411 more words
Advertisements