Question

We have a REST service using apache CXF. Can we use Jersey client to call this service.

Is there any mistake?

Was it helpful?

Solution

The idea of a web service is to allow communication between hetrogenous systems. 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. So in your case you should be able to call a REST services developed using Apache CFX using the jersey client. As both the frameworks follows the JAX-RS spec.

OTHER TIPS

Like said above, you can use even simple Http client to consume the REST service. With HTTP, you can easily perform GET, PUT, POST, DELETE Example of simple http client for your reference

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top