我正在构建一个 web 服务,但是当我测试 webservice 时发生错误。并且 wsdl 文件也没有生成。所以如何从 web 服务生成 wsdl 文件?我使用了 netbeans IDE 6.9.1。我的代码如下:
@WebService(targetNamespace = "http://my.org/ns/")
public class vendor1 implements Serializable {
static String licenseType = "Subscription";
String re = "successfully";
@WebMethod(operationName = "licence")
public String licence(@WebParam(name = "fullName") String fullName, @WebParam(name = "company") String company, @WebParam(name = "emailID") String emailID, @WebParam(name = "phone") String phone, @WebParam(name = "address") String address, @WebParam(name = "city") String city, @WebParam(name = "state") String state, @WebParam(name = "country") String country, @WebParam(name = "zipcode") String zipcode, @WebParam(name = "productID") String productID, @WebParam(name = "activationPeriod") int levelID, @WebParam(name = "levelID") int activationPeriod, @WebParam(name = "password") String password) throws Exception {
Connection con = connectToDb();
re = insertIntoCustomerTlb(con, fullName, company, emailID, phone, address, city, state, country, zipcode, productID, levelID);
re= insertIntoLicenseKeyTlb(con, emailID, licenseType, fullName, productID, activationPeriod);
re=insertIntoNoOfLicensesTlb(con, emailID);
con.close();
//String re="successfully";
return re;
}
public Connection connectToDb() throws ClassNotFoundException, SQLException {
Connection con = null;
// String re = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "plm";
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver);
con = DriverManager.getConnection(url + db, "root", "root");
return con;
}
public String insertIntoCustomerTlb(Connection con, String fullName, String company, String email, String phone, String address, String city, String state, String contry, String zipCode, String productID, int levelID) {
if (company == null) {
company = " ";
}
/*if(address==null)
{
address=" ";
}
if(city==null)
{
city=" ";
}
if(state==null)
{
state=" ";
}
String re=null;*/
/*Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "jdbctutorial";
String driver = "com.mysql.jdbc.Driver";*/
String CustomerInfoQuery = "insert into `tlb_customer_master`(`Full_Name`,`Company`,`Email`,`Phone`,`Address`,`City`,`State`,`Country`,`Zip_Code`,`Product_ID`,`Level_ID`) values (?,?,?,?,?,?,?,?,?,?,?)";
//try{
// Class.forName(driver);
//con = DriverManager.getConnection(url+db,"root","root");
try {
//Statement st = con.createStatement();
//int rowsAffected =st.executeUpdate(");
// System.out.println("1 row affected");
PreparedStatement ps = con.prepareStatement(CustomerInfoQuery);
ps.setString(1, fullName);
ps.setString(2, company);
ps.setString(3, email);
ps.setString(4, phone);
ps.setString(5, address);
ps.setString(6, city);
ps.setString(7, state);
ps.setString(8, contry);
ps.setString(9, zipCode);
ps.setString(10, productID);
ps.setInt(11, levelID);
ps.execute(CustomerInfoQuery);
ps.close();
} catch (SQLException s) {
re = "error";
}
return re;
}
public String insertIntoCustomerValidationTlb(Connection con, String email, String password) {
String CustomerInfoQuery = "insert into `tlb_customer_validation_master`(`Email`,`Password`) values (?,?)";
try {
PreparedStatement ps = con.prepareStatement(CustomerInfoQuery);
ps.setString(1, email);
ps.setString(2, password);
ps.execute(CustomerInfoQuery);
ps.close();
} catch (SQLException s) {
re = "error";
}
return re;
}
public String insertIntoLicenseKeyTlb(Connection con, String emailID, String licenseType, String fullName, String productID, int activationPeriod) {
try {
Statement st = con.createStatement();
if (activationPeriod == 1) {
String queryLicenseKey1 = "insert into `tlb_license_key_master`(`Email`,`License_Type`,`Full_Name`,`Product_ID`,`Activation_Date`,`Expiry_Date`) VALUES('" + emailID + "','" + licenseType + "','" + fullName + "','" + productID + "',now(),DATE_ADD(now(), INTERVAL 1 MONTH))";
// String queryLicenseKey2 ="insert into tlb_license_key_master (Major_Version,Minor_Version) values(select Major_Version,Minor_Version from tlb_product_master where Product_ID="+productID+")";
int rowsAffected1 = st.executeUpdate(queryLicenseKey1);
}
if (activationPeriod == 6) {
String queryLicenseKey1 = "insert into `tlb_license_key_master`(`Email`,`License_Type`,`Full_Name`,`Product_ID`,`Activation_Date`,`Expiry_Date`) VALUES('" + emailID + "','" + licenseType + "','" + fullName + "','" + productID + "',now(),DATE_ADD(now(), INTERVAL 6 MONTH))";
// String queryLicenseKey2 ="insert into tlb_license_key_master (Major_Version,Minor_Version) values(select Major_Version,Minor_Version from tlb_product_master where Product_ID="+productID+")";
int rowsAffected1 = st.executeUpdate(queryLicenseKey1);
}
if (activationPeriod == 12) {
String queryLicenseKey1 = "insert into `tlb_license_key_master`(`Email`,`License_Type`,`Full_Name`,`Product_ID`,`Activation_Date`,`Expiry_Date`) VALUES('" + emailID + "','" + licenseType + "','" + fullName + "','" + productID + "',now(),DATE_ADD(now(), INTERVAL 12 MONTH))";
// String queryLicenseKey2 ="insert into tlb_license_key_master (Major_Version,Minor_Version) values(select Major_Version,Minor_Version from tlb_product_master where Product_ID="+productID+")";
int rowsAffected1 = st.executeUpdate(queryLicenseKey1);
}
//int rowsAffected2 =st.executeUpdate(queryLicenseKey2);
st.close();
} catch (SQLException ex) {
re = "error";
}
return re;
}
public String insertIntoNoOfLicensesTlb(Connection con, String emailID) {
try {
String queryNoOfLicenses1 = "select * from tlb_no_of_licenses where Email= '" + emailID + "'";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(queryNoOfLicenses1);
int count = 0;
while (rs.next()) {
count++;
}
if (count == 0) {
String queryNoOfLicenses2 = "insert into `tlb_no_of_licenses` values('" + emailID + "',1,1,0)";
int rowsAffected2 = st.executeUpdate(queryNoOfLicenses2);
} else {
String queryNoOfLicenses2 = "UPDATE `tlb_no_of_licenses` SET No_Of_Licenses=No_Of_Licenses+1,Active_Licenses=Active_Licenses+1,Disabled_Licenses=No_Of_Licenses-Active_Licenses";
int rowsAffected2 = st.executeUpdate(queryNoOfLicenses2);
}
rs.close();
st.close();
} catch (SQLException ex) {
re = "error";
}
return re;
}
public String insertBillingTlb(Connection con, String email) {
String CustomerInfoQuery = "insert into `tlb_customer_validation_master`(`Email`,`Bill_Paid`) values (?,?)";
try {
PreparedStatement ps = con.prepareStatement(CustomerInfoQuery);
ps.setString(1, email);
ps.setString(2, "N");
ps.execute(CustomerInfoQuery);
ps.close();
} catch (SQLException s) {
re = "error";
}
return re;
}
}