2013年8月24日星期六

MyEclipse to generate web service error Unable to createJAXBContext

Brother try to use myeclipse generate web service, but always reported Unable to create JAXBContext Error
package org.course.design.bean;

public class Customer {
private String cid;  //客户编号
private String from;  //查询起始日期
private String to;    //查询截止日期

public Customer(String cid, String from, String to) {
super();
this.cid = cid;
this.from = from;
this.to = to;
}

public String getCid() {
return cid;
}

public void setCid(String cid) {
this.cid = cid;
}

public String getFrom() {
return from;
}

public void setFrom(String from) {
this.from = from;
}

public String getTo() {
return to;
}

public void setTo(String to) {
this.to = to;
}

}


package org.course.design.bean;

public class Sale {
private String cid;
private String gid;
private String salesTime;
private int goodsCount;

public String getCid() {
return cid;
}

public void setCid(String cid) {
this.cid = cid;
}

public String getGid() {
return gid;
}

public void setGid(String gid) {
this.gid = gid;
}

public String getSalesTime() {
return salesTime;
}

public void setSalesTime(String salesTime) {
this.salesTime = salesTime;
}

public int getGoodsCount() {
return goodsCount;
}

public void setGoodsCount(int goodsCount) {
this.goodsCount = goodsCount;
}
}


package org.course.design.webservice;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import org.course.design.bean.Customer;
import org.course.design.bean.Sale;

public class QueryFun {
// 输入客户对象,查询数据库,返回一个销售记录集合
public  List<Sale> query(Customer c){
//查询语句
String queryString = "select * from sale where cid='"+c.getCid()+"'";

//对起始日期和截止日期进行处理,仅当二者皆不为空的时候进行结合查询,否则只进行客户编号查询
if(!c.getFrom().equals("") && !c.getTo().equals("")){
queryString = queryString + " and salesTime between '" + c.getFrom() 
             + "' and '" + c.getTo() + "'";
}

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
        List<Sale> sales = new ArrayList<Sale>();
       
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/xmlcoursedesign", "root", "333333");
stmt = conn.createStatement();
rs = stmt.executeQuery(queryString);

while (rs.next()) {
Sale s = new Sale();
s.setCid(rs.getString("cid"));
s.setGid(rs.getString("gid"));
s.setSalesTime(rs.getString("salesTime"));
s.setGoodsCount(rs.getInt("goodsCount"));

sales.add(s);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally{
try{
if(rs != null)
rs.close();
if(stmt != null)
stmt.close();
if(conn != null)
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}

return sales;
}
}


seeking an experienced brother helper ....
------ Solution -------------------------- ------------------
you with what xfire axis2?
------ Solution ---------------------------------------- ----
If the last is not generated, it would be better to generate a plain text sent in the past forget
------ Solution ------------- -------------------------------
your wsdl file address for it?
------ For reference only -------------------------------------- -

JAX-WS
------ For reference only --------------------------- ------------

I am using myeclipse generated directly under QueryFun class.
------ For reference only -------------------------------------- -
this problem solved? I also always out of this error, webservice generate total return objects unsuccessful.
------ For reference only -------------------------------------- -
pro, do you solve this problem, I also encountered the same problem, headache ah
------ For reference only ------------ ---------------------------
finally found the reason is the default JAX-WS supports only int, String type of data returned to the client end, but it is considered to return a String data type, if the server using a custom complex type or prompts that mistake. We should put a custom complex types in List then returned List. Response time on the client and then get back to List, and then JAX-WS will automatically extract the custom class, so you can return the customer information. Hoping to help.
hey, finally doing a good job!
------ For reference only -------------------------------------- -



can detail what, I find online, and many are not resolved, can be given a demo, solve this problem, the child has not yet seen such a demo! Make one out, but also NCKU god! My looks like is a list , how to operate, I was a rookie! Seeking guidance!

没有评论:

发表评论