Dear Javaranch members,
I am new to
java and Webservices.
I am working on a university project to connect
test instruments and get request and response from it using webservice.
I have to request more than one service from the instrument, but when i use more than two @Get in the server, i get an error in browser saying "Cannot access WADL, please restart your restful webservice"
This is my code,
@GET
@Produces("text/html")
public
String getHtml() {
String ins_name=null;
try {
String [] env=null;
//setting the environment variable.
String[]callAndArgs= {"python","instrument_name.py"};//python and file name
Process p = Runtime.getRuntime().exec(callAndArgs,env,
new java.io.File("C:\\Users\\Balkishore\\Documents\\NetBeansProjects\\DemoApp1\\build\\web"));//excuting python file
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));//geting the vaue from python file
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));// reading the error
ins_name = stdInput.readLine();//reading the output from the pyhton file
System.out.println(ins_name);
}
catch (IOException e) {//catching the exception
System.out.println("exception occured");
e.printStackTrace();
System.exit(-1);
}
return ins_name;//returning the instrument name
}
@GET
@Produces("text/html")
public String getHtml1() {
String check=null;
String c1="hjhj";
String [] env=null;
//setting the environment variable.
try{
String[]callAndArgs= {"python","check_connection.py",c1};//python and file name
Process p = Runtime.getRuntime().exec(callAndArgs,env,
new java.io.File("C:\\Users\\Balkishore\\Documents\\NetBeansProjects\\DemoApp1\\build\\web"));//excuting python file
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));//geting the vaue from python file
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));// reading the error
check= stdInput.readLine();//reading the output from the pyhton file
System.out.println();
}
catch (IOException e) {//catching the exception
System.out.println("exception occured");
e.printStackTrace();
System.exit(-1);
}
return check;
}
/**
* Web service operation
}
/**
* PUT method for updating or creating an instance of GenericResource
* @param content representation for the resource
* @return an HTTP response with content of the updated or created resource.
*/
@PUT
@Consumes("text/html")
public String putHtml(String interface_name) {
try {
String [] env=null;
String[]callAndArgs= {"python","connection.py",this.interface_name=interface_name};//python file with agruments
Process p = Runtime.getRuntime().exec(callAndArgs,env,
new java.io.File("C:\\Users\\Balkishore\\Documents\\NetBeansProjects\\DemoApp1\\build\\web"));//excuting the python file
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));//getting the input
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));//getting the error
interface_name = stdInput.readLine();//reading the output
System.out.println(interface_name);
}
catch (IOException e) {//catching the exception
System.out.println("exception occured");
e.printStackTrace();
System.exit(-1);
}
return interface_name;
}
}
I have also attached the image of the error message.
Any help would be very much appreciated.
Thank you very much in advance.
Cheers,
Kishore.