Friday, November 7, 2014

View Remote Server Console with using Java


View Remote Server Console with using Java

In the software development, the developer spend significant amount of time for debug the code and reproduce the bug for find the issues and solutions. In the JEE applications almost all the errors are identified through the servers console. The best practice, developers debug the code in their local server and try to reproduce the bug, in case if it is not possible, download the remote server logs local machines and identify the issues.

The following tutorial going to explain that, how we are going to view the remote server console in local machine with using the Java application. It may helps to developers to reduce the time for analysis.

Objective : The main objective of the tutorial is view the remote server console with using Java application.

Scope : Write a simple java code for view the server console which was run remotely.

Requirements : The below basic requirements we need to set it in order to achieve our objective.
  • Eclipse Java EE IDE 
  • jsch-0.1.50.jar. The jar you able to download from here.

Step 1 : Create a new Java project in Eclipse and name it as "ViewRemoteServerConsole".
The path of creating the new Java project is below mentioned.
                    File > New > Java Project

Step 2 : Create a "RemoteConnector" java class under the "com.findanidea.remote.connector" package.

The following class create the channel with using jsch along with given input parameters.

/ViewRemoteServerConsole/src/com/findanidea/remote/connector/RemoteConnector.java


package com.findanidea.remote.connector;

import java.io.InputStream;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class RemoteConnector {

 public static void main(String[] arg) {

  try {
   JSch jsch = new JSch();
   String host="",user="",passwd = null;

   if (arg.length == 3) {
    host = arg[0];
    user = arg[1];
    passwd = arg[2];
   }else{
    System.out.println("Wrong parameters... ");
    System.out.println("Please provide the host as first parameter...");
    System.out.println("Please provide the user as second parameter...");
    System.out.println("Please provide the password as third parameter...");
   }
   Session session = jsch.getSession(user, host, 22);
   session.setPassword(passwd);

   ServerDetails ui = new ServerDetails() {
    public boolean promptYesNo(String message) {
     return true;
    }
   };

   session.setUserInfo(ui);
   session.connect(3000); 

   Channel channel = session.openChannel("shell");
   channel.setInputStream(System.in);
   channel.setOutputStream(System.out);


   InputStream in = channel.getInputStream();
   channel.connect(3 * 1000);
   byte[] tmp = new byte[1024];
   while (true) {
    while (in.available() > 0) {
     int i = in.read(tmp, 0, 1024);
     if (i < 0)
      break;
     System.out.print(new String(tmp, 0, i));
    }
    if (channel.isClosed()) {
     System.out.println("Channel is Coluse : Status is : " + channel.getExitStatus());
     break;
    }
    try {
     Thread.sleep(1000);
    } catch (Exception ee) {
    }
   }

  } catch (Exception e) {
   System.out.println(e);
  }
 }

}

In the above class file expects the 3 run time input parameters. There are,
1. host (ex: 172.19.11.11)
2. username (ex : testuser)
3. password (ex : password)


Based on the above mentioned parameters the channel will create and connect to the remote server console. 

Step 3 : Create a "ServerDetails" class under the same "com.findanidea.remote.connector" package.



package com.findanidea.remote.connector;

import com.jcraft.jsch.UIKeyboardInteractive;
import com.jcraft.jsch.UserInfo;

public class ServerDetails implements UserInfo,UIKeyboardInteractive {

 @Override
 public String[] promptKeyboardInteractive(String arg0, String arg1, String arg2, String[] arg3, boolean[] arg4) {
  return null;
 }

 @Override
 public String getPassphrase() {
  return null;
 }

 @Override
 public String getPassword() {
  return null;
 }

 @Override
 public boolean promptPassphrase(String arg0) {
  return false;
 }

 @Override
 public boolean promptPassword(String arg0) {
  return false;
 }

 @Override
 public boolean promptYesNo(String arg0) {
  return false;
 }

 @Override
 public void showMessage(String arg0) {
 }

}

All right... We did it... Now the time to test the application... 


If you execute the "RemortConnector" class with the input parameters such as remote server host, username and password, you able to see the remote server console with in you application console. 



You can find here the way for set the run time parameters in eclipse.

Hope its help to you..

Tuesday, November 4, 2014

Quartz Scheduler Application in Java

Quartz Scheduler Simple Application in Java

Most of the time Quartz is helps to Java developers to build the schedule based applications. In the Quartz, developers able to schedule the job for predefined date and time. Developers able to define multiple schedule jobs in a single application.

In this tutorial you able to learn for how to schedule the simple job with using Quartz. 

Objective : In this tutorial we are going to develop a scheduler application with using Quartz and print the Welcome message in console at predefined time period.

Scope : Develop a Scheduler application with using Quartz.

Requirements : In order to achieve the above objective we need to set it up the below items.
  • Eclipse Java EE IDE
  • Maven

Step 1 : Create a Maven project as "SpringQuartzSample" with using Eclipse. 

While you creating the project provide the input parameters are below.
 - New > Other > Maven > Maven Project
 - Click Next button with out modify any default settings.
 - The default archetype is "maven-archetype-quickstart". No need to change any of the default setting click Next.
 - Enter "TestQuartz" as GroupId, "SpringQuartzSample" as artifactId and "com.findanidea.quartz.service" as package .

Step 2 :  Update the pom.xml as mentioned below.
In this pom.xml file we specified the spring also one of the dependency in addition of quartz.

/SpringQuartzSample/pom.xml


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<project
    xmlns = "http://maven.apache.org/POM/4.0.0"
    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>TestQuartz</groupId>
    <artifactId>SpringQuartzSample</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>SpringQuartzSample</name>
    <url>http://maven.apache.org</url>
    <properties>
        <spring.version>3.1.1.RELEASE</spring.version>
        <log4j.version>1.2.16</log4j.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.2</version>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>opensymphony</groupId>
            <artifactId>quartz</artifactId>
            <version>1.6.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1</version>
        </dependency>
    </dependencies>
</project>


Step 3 : Create "TestService" class under the package defined in the step 1.

The following service method will invoke the time we specified as cron expression. 

/SpringQuartzSample/src/main/java/com/findanidea/quartz/service/TestService.java


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
package com.findanidea.quartz.service;

import java.util.Date;
import org.springframework.stereotype.Service;

@Service
public class TestService {
 public int counter = 0;

 public void testServiceMethod() {
  Date date = new Date();
  System.out.println(counter + "  - The testServiceMethod() invoked: "
      + date.toString() + "."
      + " Welcome to findanidea.blogspot.com");
  counter++;
 }
}


Step 4 : Now the time to play with the spring configurations. In the below spring configuration file we defined the following items.

1. TestService class defined in the line number 11 as testService Bean.
2. In the line number 16 configured the testServiceMethod as targetMethod in jobDetail bean.
3. The cron expression configured in the line number 22 as cronExpression property in the cronTrigger bean.
4. Finally the cron trigger added to the schedule factory bean at line number 28.

/SpringQuartzSample/src/main/resources/spring-config.xml


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd">


 <!-- Our test service bean -->
 <bean id="testService" class="com.findanidea.quartz.service.TestService" />

 <bean id="jobDetail"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  <property name="targetObject" ref="testService" />
  <property name="targetMethod" value="testServiceMethod" />
  <property name="concurrent" value="false" />
 </bean>

 <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail" ref="jobDetail" />
  <property name="cronExpression" value="0/2 * * * * ?" />
 </bean>

 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  <property name="triggers">
   <list>
    <ref bean="cronTrigger" />
   </list>
  </property>
  <property name="quartzProperties">
   <props>
    <prop key="org.quartz.scheduler.skipUpdateCheck">true</prop>
   </props>
  </property>
 </bean>

</beans>


You able to define multiple schedule jobs with different cron expression in a single "SchedulerFactoryBean" bean.

That's all...  Now move to next step for test the quartz service.

Step 5 : Create a "RunTest" class under the "com.findanidea.quartz.service" package. In the following class we specified that, the thread sleep time at 30 sec.

/SpringQuartzSample/src/main/java/com/findanidea/quartz/service/RunTest.java


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.findanidea.quartz.service;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class RunTest {
 public static void main(String[] args) {

  ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-config.xml");
  System.out.println("*************************************************************************");
  System.out.println("***************** The Quarts Service going to Start. ********************");
  System.out.println("*************************************************************************");
  try {
   Thread.sleep(30000);
  } catch (InterruptedException ex) {
   System.out.println(ex.getMessage());
  }
  System.out.println("*************************************************************************");
  System.out.println("***************** The Quarts Service Stoped. ********************");
  System.out.println("*************************************************************************");
  applicationContext.stop();

 }
}

Once execute the RunTest class, then you able to see the below output in your console...


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
INFO: Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED started.
*************************************************************************
***************** The Quarts Service going to Start. ********************
*************************************************************************
0  - The testServiceMethod() invoked: Tue Nov 04 12:53:54 IST 2014. Welcome to findanidea.blogspot.com
1  - The testServiceMethod() invoked: Tue Nov 04 12:53:56 IST 2014. Welcome to findanidea.blogspot.com
2  - The testServiceMethod() invoked: Tue Nov 04 12:53:58 IST 2014. Welcome to findanidea.blogspot.com
3  - The testServiceMethod() invoked: Tue Nov 04 12:54:00 IST 2014. Welcome to findanidea.blogspot.com
4  - The testServiceMethod() invoked: Tue Nov 04 12:54:02 IST 2014. Welcome to findanidea.blogspot.com
5  - The testServiceMethod() invoked: Tue Nov 04 12:54:04 IST 2014. Welcome to findanidea.blogspot.com
6  - The testServiceMethod() invoked: Tue Nov 04 12:54:06 IST 2014. Welcome to findanidea.blogspot.com
7  - The testServiceMethod() invoked: Tue Nov 04 12:54:08 IST 2014. Welcome to findanidea.blogspot.com
8  - The testServiceMethod() invoked: Tue Nov 04 12:54:10 IST 2014. Welcome to findanidea.blogspot.com
9  - The testServiceMethod() invoked: Tue Nov 04 12:54:12 IST 2014. Welcome to findanidea.blogspot.com
10  - The testServiceMethod() invoked: Tue Nov 04 12:54:14 IST 2014. Welcome to findanidea.blogspot.com
11  - The testServiceMethod() invoked: Tue Nov 04 12:54:16 IST 2014. Welcome to findanidea.blogspot.com
12  - The testServiceMethod() invoked: Tue Nov 04 12:54:18 IST 2014. Welcome to findanidea.blogspot.com
13  - The testServiceMethod() invoked: Tue Nov 04 12:54:20 IST 2014. Welcome to findanidea.blogspot.com
14  - The testServiceMethod() invoked: Tue Nov 04 12:54:22 IST 2014. Welcome to findanidea.blogspot.com
*************************************************************************
***************** The Quarts Service Stoped. ********************
*************************************************************************







In the above output able to see that the welcome message printed every 2 sec.

Additional details : 
  • You able to find the Quartz API here.
  • Using the "CronMaker" you able to create an cron expression based on your requirements.


Monday, November 3, 2014

Create web service with using axis2 in eclipse


Create web service with using Axis2 in eclipse

These days web service technology is widely using in the Java EE applications. The most common reason is that, the web service is the way of communicate different applications even the applications are deployed in different plat form. For example if the currency exchange web service is build in Dot Net and deployed in one server. If another application written in Java and running in different server, that able to use the currency exchange service, (The service already developed in Dot Net) via web service client. The communication can be possible with using the XML messages over the HTTP protocol.

There are main two type of web services available. One was SOAP (Simple Object Access Protocol). The second was RestFul (Representational State Transfer). 

There are two approaches commonly used, when develop the web services.
1. top to bottom approach (WSDL to Java)
2. bottom to top approach (Java to WSDL)

The below tutorial will explain for, how to create the Soap web services based on top to bottom approach with using the Axis2.

Scope : Create a web service with using Axis2 in eclipse with using top to bottom approach.

Objective : Create an web service using Axis2 and the service operation return the Welcome message with given username.

Requirements : 
  • Eclipse Java EE IDE
  • axis2-1.6.2
  • Apache Tomcat - 6.0.26
Step 1 : Create a Dynamic web project "webservice" in eclipse. The way of creating the dynamic web project mentioned as below.
                 New > Dynamic web project

Step 2 : Copy the WSDL (you able to find here ) in to the project created in the Step 1. (/webservice/helloworld.wsdl)

Step 3 : Create the web service project as mentioned in below.
Right Click on the "webservice" project > New > Other > Web Service > Web Service

Step 4 : The following screen will appear. 



In the screen choose the "Top down Java bean Web Service" as Web service Type and choose the WSDL path as Service definition.

Select the server runtime as Tomcat 6.0 and Web service runtime as Apache Axis 2.

Step 5 : Click the next button and specify the package name for the service classes which going to generate by Axis based on the WSDL.

In this example package name specified as "findanidea.webservice.services.helloworld" .

Step 6 : Click the next button, and wait... After some time the auto generated code added to your project. 

The following java classes are generated based on the WSDL provided.




Step 7 : Do not start the server at this point and finished the wizard at this level. Now the time comes to develop the service implementation.

Step 8 : In the generated "HelloworldSkeleton" class need to incorporate the business logic.

In the below code line 3 to 5 we commented, which was auto generated when create the service. In addition to that, the business logic implemented in line number 7 and 8.

For this example, the response object contains the combination of strings Hello and name as Output property. 


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
public localhost.webservice.services.helloworld.SayHelloResponse sayHello(
   localhost.webservice.services.helloworld.SayHello sayHello) {
  /*// TODO : fill this with the necessary business logic
  throw new java.lang.UnsupportedOperationException("Please implement "
    + this.getClass().getName() + "#sayHello");*/
  
  SayHelloResponse response = new SayHelloResponse();
  response.setOutput("Hello... " + sayHello.getName());
  return response;
 }

Deploy the service to server.

Step 9 : Now the time to test the service service level, which we developed at Step 8.

Write the following "TestService" class under the below package. "findanidea.webservice.services.helloworld"

/webservice/src/findanidea/webservice/services/helloworld/TestService.java


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
package findanidea.webservice.services.helloworld;

import findanidea.webservice.services.helloworld.SayHello;

public class TestService {
 public static void main(String[] args) {
  HelloworldSkeleton skeleton = new HelloworldSkeleton();
  SayHello sayHello = new SayHello();
  sayHello.setName("John");
  System.out.println(skeleton.sayHello(sayHello).getOutput());
 }
}

Step 10 : That's all folks... Now if run the "TestService" class you able to get the following response in the console.


1
Hello... John

Thursday, October 30, 2014

Java MySQL UPDATE Using PreparedStatement


Java MySQL UPDATE Using PreparedStatement

In the Java applications there are several ways to update the data base records. The more convenient way is using the PreparedStatement for update the data base records by sending the SQL statements.

In this tutorial we used the PreparedStatements for update the records available in MySQL data base.

Scope : Update the table records in MySQL with using Prepared Statement.

Objective : Update the table records in MySQL with using Prepared Statement.

Requirements :
  • Eclipse Java EE IDE
  • MySQL Server 5.5
Step 1 : Create an Java project in Eclipse and name it as "UpdateExample". 

Step 2 : Download the "mysql-connector.jar" from here and add to the project build path.

Step 3 : Create a table Student in MySQL test database with using following script.


1
2
3
4
5
6
CREATE TABLE `test`.`Students` (
  `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `firstname` VARCHAR(45) NOT NULL DEFAULT '',
  `email` VARCHAR(50) NOT NULL DEFAULT '',
  PRIMARY KEY(`id`)
);

Insert the following records to the Student table which we already created with using the above script.


1
2
insert into users (firstname, email) values ('John', 'john@gmail.com');
insert into users (firstname, email) values ('Tester', 'Tester@test.com');


Step 4 : Create a class "PreparedStatementUpdate" under the "com.findanidea.update" package.

The MySql driver and the url defined as private static final instance variable at line numbers 10 and 11.

The Connection created at the line number 15 with using the getConnection method. The SQL statement for update the records specified in the line number 18. The input parameters defined in order in line numbers 20 and 21. 

Finally the prepared statement executed at line number 24 and if its executed successfully the message specified in the line number 25 will print at the application console.

/UpdateExamle/src/com/findanidea/update/PreparedStatementUpdate.java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.findanidea.update;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class PreparedStatementUpdate {
 
 private static final String myDriver = "com.mysql.jdbc.Driver";
 private static final String myUrl = "jdbc:mysql://localhost:3306/test";
 public static void main(String[] args) {
  try {
   
   Connection conn = getConnection();

   // create the update preparedstatement
   String query = "update student set email = ? where firstname = ?";
   PreparedStatement preparedStmt = conn.prepareStatement(query);
   preparedStmt.setString(1, "tester@test.com");
   preparedStmt.setString(2, "John");

   // execute the preparedstatement
   preparedStmt.executeUpdate();
   System.out.println("Record updated Successfully.");
   conn.close();
  } catch (Exception e) {
   System.err.println("Exception Occurs!!!!");
   System.err.println(e.getMessage());
  }
 }
 
 private static Connection getConnection() throws ClassNotFoundException, SQLException {
  Class.forName(myDriver);
  Connection conn = DriverManager.getConnection(myUrl, "root", "1234");
  return conn;
 }
}


Step 5 : Once execute the above mentioned class in the Step 4, you able to see the below out put at your application console.


1
Record updated Successfully.

Tuesday, October 28, 2014

How to create WSDL in Eclipse


How to create WSDL in Eclipse

WSDL (Web Service Description Language) is one of the core part of the web service development. In the WSDL file we defines what are the operations going to performs, how to access the services and service url end point etc. 

In the below tutorial you able to learn that, how to create the WSDL file for simple string manipulation function.

Objective : Create a WSDL with using eclipse.

Scope : Create a WSDL in eclipse and validate which is serve welcome message as a service response.

Requirements : 
  • Eclipse Java EE IDE

Step 1 : Create a java project in eclipse and name it as "WSDL".

Step 2 : Select the "WSDL" project and create a new WSDL file as below.
 - Right click of "WSDL" project > New > Other 
 - The New Select a wizard will appear.
 - Select Web Service > WSDL and click "Next" button on the wizard.
 - You have to name the WSDL at this point. Just name it as "helloworld.wsdl".





 - From the following wizard screen, except the Target name space rest of the settings kept as it is. Further more details of the setting able to find here.



 - Finally click the finish button.

Step 3 : Change the address to "http://localhost:8181/webservice/services/helloworld/". 

In future we are going to generate a service and client based on the WSDL created in this tutorial. 

The default operation name changed to "newOperation" to "sayHello" and save it.

The WSDL source looks like below.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8181/webservice/services/helloworld/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="helloworld" targetNamespace="http://localhost:8181/webservice/services/helloworld/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://localhost:8181/webservice/services/helloworld/">
      <xsd:element name="sayHello">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="name" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="sayHelloResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="output" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="sayHelloRequest">
    <wsdl:part element="tns:sayHello" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="sayHelloResponse">
    <wsdl:part element="tns:sayHelloResponse" name="parameters"/>
  </wsdl:message>
  <wsdl:portType name="helloworld">
    <wsdl:operation name="sayHello">
      <wsdl:input message="tns:sayHelloRequest"/>
      <wsdl:output message="tns:sayHelloResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="helloworldSOAP" type="tns:helloworld">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHello">
      <soap:operation soapAction="http://localhost:8181/webservice/services/helloworld/sayHello"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="helloworld">
    <wsdl:port binding="tns:helloworldSOAP" name="helloworldSOAP">
      <soap:address location="http://localhost:8181/webservice/services/helloworld/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


Step 4 : For validate the WSDL just right click on the WSDL source and Validate. If any errors occurs its pointed with red color.