java.lang.IllegalArgumentException:com.bidda.Retrive不是接口

时间:2017-04-16 18:16:40

标签: java web-services servlets soap wsdl

我使用以下代码创建了一个Web服务Retrive:

 @WebService(serviceName = "Retrive")
public class Retrive {

/**
 * This is a sample web service operation
 */
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
    return "Hello " + txt + " !";
}

/**
 * Web service operation
 */
@WebMethod(operationName = "getData")
public List<String> getData(@WebParam(name = "parameter") String parameter) {
    //TODO write your implementation code here:
    List<String> haha = new ArrayList<String>();
    try{


     Class.forName("com.mysql.jdbc.Driver");


     Connection con=DriverManager.getConnection
                    ("jdbc:mysql://localhost:3306/ws_pbl","root","");
     PreparedStatement ps =con.prepareStatement
                         ("SELECT * FROM ws_pbl.courses where name LIKE '%"+parameter+"%'");
       ResultSet rs =ps.executeQuery();
       while(rs.next()){
       haha.add(rs.getString("name"));
       }

     }catch(ClassNotFoundException | SQLException e)
  {


}
     return haha;}}

我创建了一个使用以下代码调用Web服务的java servlet:

public class Test extends HttpServlet {
    @WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/bidda/Retrive.wsdl")
    private Retrive_Service service;



@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
PrintWriter out = response.getWriter();


 out.print(getData("data").toString());  } private java.util.List<java.lang.String> getData(java.lang.String parameter) {
        // Note that the injected javax.xml.ws.Service reference as well as port objects are not thread safe.
        // If the calling of port operations may lead to race condition some synchronization is required.
        com.bidda.Retrive port = service.getRetrivePort();
        return port.getData(parameter);
    }

当我运行servlet并在Netbeans中调用Web服务时,我收到以下错误:

  

java.lang.IllegalArgumentException:com.bidda.Retrive不是接口

0 个答案:

没有答案