Simple SOAP Server in Java

Create a Web Application (MyWebServices) in NetBeans. Create a class with annotations

public class MyWebService {

	@WebMethod(operationName = "printName")
	public String printName(@WebParam(name = "userName") String userName) {

		return "hello " + userName;

	public int[] getArr() {
		int[] i = { 1, 1, 2, 3, 4 };
		return i;

Map the path in web.xml file


Deploy the project and the web service is ready to be used.Automatically the web service endpoint becomes like

To test the web service I created a simple PHP soap client.

$soap = new SoapClient("http://localhost:8080/MyWebServices/MyWebService?wsdl",array(
										'trace' => true,
										'exceptions' => true,));
$name = $soap->printName(array("userName" => "Dave"));
$arr = $soap->getArr();