Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This example will lead you through creating your first service with doing "code first" development with JAX-WS. You'll learn how to:

  • Set up your build for CXF
  • Writing a simple JAX-WS service
  • Publish your service using the JAX-WS APIs

Table of Contents

This example corresponds to the hello_world_code_first example in the CXF distribution. IMPORTANT: This sample is only in CXF 2.0.1+!

...

Pointing your browser at http://localhost:9000/helloWorld?wsdl will display the wsdl for this service

Accessing your service

and client code to see it working is at http://svn.apache.org/repos/asf/incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/client/Client.java

For the client there is also the alternative approach that gives you more flexibility. Of course like above the logging interceptors are optional but they help a lot when starting:

Code Block

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingInInterceptor());
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:9000/helloWorld");
HelloWorld client = (HelloWorld) factory.create();

String reply = client.sayHi("HI");
System.out.println("Server said: " + reply);
System.exit(0);