Creating Web services using Apache CXF (Part 4): Testing

To test this we can follow the same client program which is given in the CXF site.

Just create a simple Java class and execute it.

 1: package com.your.company.service.client;
 2:
 3: import java.util.List;
 4:
 5: import org.apache.cxf.interceptor.LoggingInInterceptor;
 6: import org.apache.cxf.interceptor.LoggingOutInterceptor;
 7: import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 8:
 9: import com.your.company.service.Product;
 10: import com.your.company.service.ProductService;
 11:
 12: public final class Client {
 13:
 14:     private Client() {
 15:     }
 16:
 17:     public static void main(String args[]) throws Exception {
 18:
 19:         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
 20:
 21:         factory.getInInterceptors().add(new LoggingInInterceptor());
 22:         factory.getOutInterceptors().add(new LoggingOutInterceptor());
 23:         factory.setServiceClass(ProductService.class);
 24:         factory.setAddress("http://localhost:8080/CXFExample/productservice");
 25:         ProductService client = (ProductService) factory.create();
 26:
 27:         List<Product> products = client.getProducts();
 28:         if (products != null && products.size() > 0)
 29:             System.out.println("Product Name : "
 30:                     + products.get(0).getItemName() + ", Price: "
 31:                     + products.get(0).getPrice());
 32:         System.exit(0);
 33:
 34:     }
 35:
 36: }

Other related posts:

1. Creating Web services using Apache CXF (Part 1) : The Basics.

2. Creating Web services using Apache CXF (Part 2) : Development.

3. Creating Web services using Apache CXF (Part 3) : Configuration.

4. Creating Web services using Apache CXF (Part 4): Testing.

Advertisements

Creating Web services using Apache CXF (Part 1) : The Basics.

As we discussed in the previous post, CXF is the combination of two projects: Celtix developed by IONA and XFire developed by Codehaus working together at the Apache Software Foundation.

 

 

Apache CXF- An ultimate web service open source framework : Lets start learning…

Apache CXF is an open source services framework which is a result of the merge between the XFire and Celtix projects. CXF helps us build and develop services using JAX-WS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI.

In this series we will go through two common approaches to create a web service.

  1. Code first approach
  2. Contract First approach

TWO good slide shows about use of Web 2.0 in Enterprise world

The following two presentations by Enterprise 2.0 Bloggers Scott Gavin and Daniel Siddle are simply great ones. If you have some time to spent then check it once. I am sure it will be helpful to you. These slideshows are very much helpful to know about the extended use of Web 2.0 in our enterprise world. I got these from Mr.Jonathan’s blog.

Meet Charlie’ is a walk through of the web based knowledge and communication tools used by an internet savvy Project Manager. 

Daniel Siddle has written ‘Meet Charlotte’ as a response. If ‘Charlie’ is where early adopters are trying to lead Enterprise IT, then ‘Charlotte’ is a brilliant contrast as to where we are now.

Technorati Tags: ,