简体   繁体   English

我们可以将jersey客户端用于Apache CXF Web服务吗?

[英]can we use jersey client for Apache CXF webservice?

We have a REST service using apache CXF. 我们有一个使用apache CXF的REST服务。 Can we use Jersey client to call this service. 我们可以使用Jersey客户端调用此服务吗?

Is there any mistake? 有没有错

The idea of a web service is to allow communication between hetrogenous systems. Web服务的思想是允许异构系统之间的通信。 So no matter what framework is used to create the web service, you should be able to call it using any client, provided both client and server conforms to the JAX-RS specifications. 因此,无论使用什么框架来创建Web服务,只要客户端和服务器都符合JAX-RS规范,您都应该能够使用任何客户端来调用它。 So in your case you should be able to call a REST services developed using Apache CFX using the jersey client. 因此,在您的情况下,您应该能够使用球衣客户端调用使用Apache CFX开发的REST服务。 As both the frameworks follows the JAX-RS spec. 由于这两个框架都遵循JAX-RS规范。

Like said above, you can use even simple Http client to consume the REST service. 如上所述,您甚至可以使用简单的Http客户端来使用REST服务。 With HTTP, you can easily perform GET, PUT, POST, DELETE Example of simple http client for your reference 使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM