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();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: