Tom Sebastian
Tom Sebastian

Reputation: 3433

can we use jersey client for Apache CXF webservice?

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

Is there any mistake?

Upvotes: 0

Views: 504

Answers (2)

Rockoder
Rockoder

Reputation: 784

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();

Upvotes: 0

Juned Ahsan
Juned Ahsan

Reputation: 68715

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.

Upvotes: 1

Related Questions