This my code for webservice.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package customer;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.jws.WebService;
/**
*
* @author Mihir
*/
public class Customer {
String date1;
Format formatter;
Date date = new Date();
public String feedback(String contactno,String comments,String ambience,String service,String
food,String email,String custno,String custname,String storeno,String sno)
{
formatter = new SimpleDateFormat("dd/MM/yy");
date1 = formatter.format(date);
Connection con = null;
PreparedStatement prest;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/feedback","root","root");
Statement stmt = con.createStatement();
String sql = "INSERT INTO fb(contact_no,
date,comments,ambience,service,food,email,cust_no,cust_name,store_no,s_no) " +
"VALUES ('"+contactno+"',
'"+date1+"','"+comments+"','"+ambience+"','"+service+"','"+food+"','"+email+"','"+custno+"',
'"+custname+"','"+storeno+"','"+sno+"')";
stmt.execute(sql);
}
catch (Exception e){
e.printStackTrace();
}
return null;
}
}
Now this is what I am trying to do.
- Creating folder in webapps in Tomcat with name customer_customer.
- Inside that two more folder - WEB-INF META-INF
Inside META_INF context.xml with content-
Inside WEB-INF
4.a. classes/customer/Customer.class
4b. lib folder with jar - I. webservices-api.jar II. webservices-extra.jar III.webservices--extra-api.jar IV. webservices-rt.jar V. webservices-tools.jar VI. mysql-connector-java-5.1.18-bin.jar
4c. web.xml -
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Customer</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Customer</servlet-name>
<url-pattern>/feedback</url-pattern>
</servlet-mapping>
</web-app>
4d. sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint implementation="ws.Customer" name="Adder" url-pattern="/feedback"/>
</endpoints>