Webservice client error
Hi can someone help me with this webservice bassically I deployed this webservice on netbeans and it ran fine however when i wanted to create a webservice client based on this webservice below it gave me the error message:
Webserice client can not be created by JAXWS import utility Reason: premature end of file there might be a problem during java atifacts creation for example a name conflict in generated classes
it also goes on to say.
to detect the problem see also the error messages in output window you may be able to fix the problem in WSDL customisation dialog (edit webservices attributes actions) or by manual editing of local WSDL or schema files using JAXB customisation local wsdl and schema files are located in xml resources directory.
package emp;
import java.util.*;
import java.io.*;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import java.util.List;
/**
*
* @author Frederick Carter
*/
@WebService()
public class BankWS {
private static Vector<Employee> staff = new Vector<Employee>();
@WebMethod(operationName = "readChoice" )
public static int readChoice() {
Scanner scnnr = new Scanner(System.in);
return scnnr.nextInt();
}
@WebMethod(operationName = "readInput" )
public static String readInput() {
Scanner scnnr = new Scanner(System.in);
return scnnr.nextLine();
}
@WebMethod(operationName = "readFileForStaff")
public static Vector<Employee> readFileForStaff() throws IOException {
String strFilePath = "./src/staff.txt";
final String NEW_LINE = "\n";
final String COMA = ",";
final String id = "id";
Vector<String> v = new Vector<String>();
Vector<Employee> empl = new Vector<Employee>();
String[] tmpString;
// reads file
Scanner fileScaner = new Scanner(new File(strFilePath));
// reads each line
fileScaner.useDelimiter(NEW_LINE);
while (fileScaner.hasNext()) {
v.add(fileScaner.next());
}
fileScaner.close(); // closes scanner
for (int i = 0; i < v.size(); i++) {
Employee em = new Employee();
// splits string into substrings
tmpString = v.get(i).split(COMA);
if (tmpString[0].equals(id)) {
em.setName(tmpString[1]);
em.setPassword(tmpString[2]);
empl.add(em);
}
}
return empl;
}
@WebMethod(operationName = "readFileForCustomer")
public static Vector<Customer> readFileForCustomer() throws IOException {
String strFilePath = "./src/customer.txt";
final String NEW_LINE = "\n";
final String COMA = ",";
final String id = "id";
Vector<String> v = new Vector<String>();
Vector<Customer> cstmr = new Vector<Customer>();
String[] tmpString;
// reads file
Scanner fileScaner = new Scanner(new File(strFilePath));
// reads each line
fileScaner.useDelimiter(NEW_LINE);
while (fileScaner.hasNext()) {
v.add(fileScaner.next());
}
fileScaner.close(); // closes scanner
for (int i = 0; i < v.size(); i++) {
Customer csr = new Customer();
// splits string into substrings
tmpString = v.get(i).split(COMA);
if (tmpString[0].equals(id)) {
csr.setName(tmpString[1]);
csr.setSurname(tmpString[2]);
csr.setAccount(tmpString[3]);
csr.setBalance(Integer.parseInt(tmpString[4]));
cstmr.add(csr);
}
}
return cstmr;
}
@WebMethod(operationName = "writeToFile")
public static void writeToFile() throws IOException {
String strFilePath = "./src/staff.txt";
BufferedWriter writer = new BufferedWriter(new FileWriter(strFilePath));
for (int i = 0; i < staff.size(); i++) {
writer.write("id," + staff.get(i).getName() + "," + staff.get(i).getPassword()+"\n");
}
writer.close();
}
@WebMethod(operationName = "writeToCustomerFile")
public static void writeToCustomerFile (@WebParam(name = "customer") List<Customer> customers) throws IOException
{
String strFilePath = "./src/customer.txt";
BufferedWriter writer = new BufferedWriter(new FileWriter(strFilePath));
for (Customer cust : customers) {
writer.write("id," + cust.getName() + "," + cust.getSurname() + "," +
cust.getAccount() + "," + cust.getBalance() + "\n");
}
writer.close();
}
@WebMethod(operationName = "checkEmployee")
public static boolean checkEmployee(@WebParam(name = "em") String em, @WebParam(name = "psswd") String psswd) {
for (int i = 0; i < staff.size(); i++) {
if (staff.get(i).getName().equalsIgnoreCase(em) && staff.get(i).getPassword().equalsIgnoreCase(psswd)) {
return true;
}
}
return false;
}
@WebMethod(operationName = "register")
public static void register(@WebParam(name = "n") String n, @WebParam(name = "p") String p) throws IOException {
Employee e = new Employee();
e.setName(n);
e.setPassword(p);
staff.add(e);
writeToFile();
}
@WebMethod(operationName = "showEmployees")
public static void showEmployees() {
System.out.println("No of employees: " + staff.size());
for (int i = 0; i < staff.size(); i++) {
System.out.println("Employee: " + staff.get(i).getName() + " " + staff.get(i).getPassword());
}
}
@WebMethod(operationName = "Initialise")
public static void Initialise() throws IOException {
staff = readFil开发者_如何学编程eForStaff();
}
}
精彩评论