2012-04-20 17 views
0

私は、テスト機器を接続し、webserviceを使用してそれから要求と応答を得るプロジェクトに取り組んでいます。複数のWebサービスにアクセスする

私は楽器から複数のサービスを要求する必要がありますが、私は、サーバーに二つ以上の@Get Sを使用する場合、私は

はWADLにアクセスできませんと言って、私のブラウザでエラーを取得し、あなたを再起動してください。安らかなWebサービスは

これは私のコードで、

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:\\fakepath\\NetBeansProjects\\DemoApp1\\build\\web"));//executing Python file 


     BufferedReader stdInput = new BufferedReader(new 
     InputStreamReader(p.getInputStream()));//getting the value from Python file  
     BufferedReader stdError = new BufferedReader(new  
     InputStreamReader(p.getErrorStream()));// reading the error  
     ins_name = stdInput.readLine();//reading the output from the Pythonfile  
     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"));//executing Python file 


     BufferedReader stdInput = new BufferedReader(new 
     InputStreamReader(p.getInputStream()));//getting the value from Python file 

     BufferedReader stdError = new BufferedReader(new 
     InputStreamReader(p.getErrorStream()));// reading the error 

     check= stdInput.readLine();//reading the output from the Python 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 arguments 

     Process p = Runtime.getRuntime().exec(callAndArgs,env, 
     new java.io.File("C:\\fakepath\\NetBeansProjects\\DemoApp1\\build\\web"));//executing 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; 
} 
} 

私は、エラーメッセージの画像を添付しています。

あなたのリソースパスに加えて、あなたの方法@Path(「/ mypathで」)ごとに異なるパスを指定しない限り、あなたは、リソースのために、「GET」の個別に定義することはできません

Error message

答えて

1

@Path("/myRes") 
public class myResource{ 

    @GET @Path("/myAttr") 
    public void getAttr(...) 
} 
+0

最初お返事ありがとうございました。私はJavaとnetbeansに非常に新しいので、私の愚かさを許してください、私はあなたがそこに何を意味を得ることができませんでしたか? html1の下に新しいパスを作成しようとしましたが、同じエラーが再び発生しています。 – Spaniard89

+0

サービスを利用するためにクライアントライブラリを使用していますか? – fmgp

+0

はい、私は私のリソースを消費するためにjframeクライアントを使用します。 – Spaniard89

関連する問題