这是我的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;
}
}
现在这就是我想做的事。
内容为META_INF的context.xml -
WEB-INF内部
4.A。 classes / customer / Customer.class
4b中。带jar的lib文件夹 - I. webservices-api.jar II。 web服务,extra.jar III.webservices - 超api.jar文件 IV。高于webservices-rt.jar V. webservices-tools.jar VI。 MySQL的连接器的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上。太阳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>
答案 0 :(得分:1)
我现在得到它并且它正在进行更改,以便我的包名称彼此不同并指定
@Webservice
在我的班级名称之前。我已经测试了Webservice并在我的Android手机上实现。
谢谢大家的意见。