Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demystifying Apache CXF: A Hello World App
package org.opensourcesoftwareandme;
public class HelloWorldImpl{
public String sayHi(String text) {
return "Hello " + text;
}
}
package org.opensourcesoftwareandme;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(serviceName = "HelloWorld")
public class HelloWorldImpl{
public String sayHi(@WebParam(name = "text") String text) {
return "Hello " + text;
}
}
...
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
...
mvn package; mvn exec:java -Dexec.mainClass="org.opensourcesoftwareandme.Server"
package org.opensourcesoftwareandme;
import javax.xml.ws.Endpoint;
public class Server {
public static void main(String args[]) throws Exception {
Endpoint.publish("http://localhost:9000/helloWorld", new HelloWorldImpl());
System.out.println("Server started...");
Thread.sleep(5 * 60 * 1000);
System.out.println("Server stopping...");
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.