2012-04-09 19 views
0

webserviceをビルドしていますが、webservice.and wsdlファイルもwebserviceからwsdlファイルを生成する方法は? .myコードは次のとおりです。WebService:wsdlファイルが生成されていません

@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; 
    } 

} 
+0

あなたの例外は掲載できますか? – maks

答えて

0

Netbeansを使用しているので、Webサービスを作成するのはかなり簡単です。

この記事を通過してください:http://netbeans.org/kb/docs/websvc/jax-ws.html

は、手順に従って、あなたは疑問を持っている場合は、それをここに投稿し

あなたはとして扱われることを望んでいないすべてのパブリックメソッドを除外する必要があります
+0

先週、私は1つのwebserviceを作成していましたが、これらのWebサービスでは同じ手順を実行しましたが、エラーは発生しました。コードを参照してください。 – tapanmodh

+0

実行中のエラーをなぜ表示しないのですか? – stefanglase

0

Webサービスメソッド:

Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions 
java.sql.Connection is an interface, and JAXB can't handle interfaces. 
    this problem is related to the following location: 
     at java.sql.Connection 
     at private java.sql.Connection jaxws.InsertIntoCustomerTlb.arg0 
     at jaxws.InsertIntoCustomerTlb 
java.sql.Connection does not have a no-arg default constructor. 
    this problem is related to the following location: 
     at java.sql.Connection 
     at private java.sql.Connection jaxws.InsertIntoCustomerTlb.arg0 
     at jaxws.InsertIntoCustomerTlb 
java.lang.StackTraceElement does not have a no-arg default constructor. 
    this problem is related to the following location: 
     at java.lang.StackTraceElement 
     at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace() 
     at java.lang.Throwable 
     at private java.lang.Throwable jaxws.ClassNotFoundExceptionBean.exception 
     at jaxws.ClassNotFoundExceptionBean 

ソリューション:すべてのパブリックメソッドに@WebMethod(exclude = true)を追加するには、Webサービスメソッド

0
として公開したくありません

-J-Djavax.xml.accessExternalSchema=allnetbeans_default_optionsを/etc/netbeans.confファイルに追加する必要があります。

この変更後、ネットビーンズはWebサービスを使用してWSDLファイルを解析できます。

関連する問題