[英]can we use jersey client for Apache CXF webservice?
我们有一个使用apache CXF的REST服务。 我们可以使用Jersey客户端调用此服务吗?
有没有错
Web服务的思想是允许异构系统之间的通信。 因此,无论使用什么框架来创建Web服务,只要客户端和服务器都符合JAX-RS规范,您都应该能够使用任何客户端来调用它。 因此,在您的情况下,您应该能够使用球衣客户端调用使用Apache CFX开发的REST服务。 由于这两个框架都遵循JAX-RS规范。
如上所述,您甚至可以使用简单的Http客户端来使用REST服务。 使用HTTP,您可以轻松执行GET,PUT,POST,DELETE简单HTTP客户端示例供您参考
URL url = null;
try {
url = new URL(urlStr);
} catch (MalformedURLException e) {
throw new Exception("Malformed URL", e);
}
HttpURLConnection con = null;
try {
if (user != null && pass != null)
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, pass
.toCharArray());
}
});
// end of authentication test
SSLUtilities.trustAllHostnames();
SSLUtilities.trustAllHttpsCertificates();
con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setAllowUserInteraction(true);
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", ConTypeGet);
s_logger.debug("Execute GET request Content-Type: "
+ con.getRequestProperty("Content-Type"));
s_logger.debug("URL:" + url);
con.connect();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.