Java 如何调用webservice中声明的webdriver?

Java 如何调用webservice中声明的webdriver?,java,web-services,selenium,selenium-webdriver,selenium-chromedriver,Java,Web Services,Selenium,Selenium Webdriver,Selenium Chromedriver,我已经在saveImage Web服务中声明了webdriver,并试图通过webresource调用它。但它是通过mappableContainer异常无法映射到资源。我尝试了以下方法,请任何人帮助解决这个问题。谢谢 @POST @Path("/helloworld") @Produces("text/plain") public String saveImage(String inputJson) throws IOException, JSONException,

我已经在saveImage Web服务中声明了webdriver,并试图通过webresource调用它。但它是通过mappableContainer异常无法映射到资源。我尝试了以下方法,请任何人帮助解决这个问题。谢谢

@POST
@Path("/helloworld")
@Produces("text/plain")
public String saveImage(String inputJson) throws IOException,
        JSONException,
        AWTException {
JSONObject inputJsonObj = new JSONObject(inputJson);
String ipAddress = (String) inputJsonObj.get("username");
System.setProperty("webdriver.chrome.driver", 
"C:\\seleniumDrivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
return ("opened selenium successfully");
}
现在我通过另一个类的webresource调用这个webservice。提到的路径是正确的

JSONObject apiJson = new JSONObject();
apiJson.put("username", "userName");
String path = "http://localhost:8585/Server/startpage/helloworld";
WebResource webResource = client.resource(path);
ClientResponse response = webResource.type("application/json")
                .post(ClientResponse.class, apiJson.toString());
在声明selenium的内部,还有其他方法调用webresource吗