Last active
August 7, 2016 15:48
-
-
Save afsinka/abb87569e2a67d12424f96ffd5ac2024 to your computer and use it in GitHub Desktop.
Apache CXF Server Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cxf.server; | |
import javax.jws.WebParam; | |
import javax.jws.WebService; | |
@WebService | |
public interface HelloWorld { | |
String sayHi(@WebParam(name = "text") String text); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cxf.server; | |
import javax.jws.WebService; | |
@WebService | |
public class HelloWorldImpl implements HelloWorld { | |
public String sayHi(String name) { | |
System.out.println("say hello to " + name); | |
return "Hello " + name + "!"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cxf.server; | |
import org.apache.cxf.jaxws.JaxWsServerFactoryBean; | |
public class Main { | |
public static void main(String[] args) { | |
HelloWorld helloWorld = new HelloWorldImpl(); | |
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); | |
factory.setServiceClass(HelloWorld.class); | |
factory.setAddress("http://localhost:9000/HelloWorld"); | |
factory.setServiceBean(helloWorld); | |
factory.create(); | |
System.out.println("Server ready..."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>CXF_Server_Example</groupId> | |
<artifactId>CXF_Server_Example</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>war</packaging> | |
<dependencies> | |
<dependency> | |
<groupId>org.apache.cxf</groupId> | |
<artifactId>cxf-rt-frontend-jaxws</artifactId> | |
<version>3.1.5</version> | |
</dependency> | |
<dependency> | |
<groupId>org.apache.cxf</groupId> | |
<artifactId>cxf-rt-transports-http</artifactId> | |
<version>3.1.5</version> | |
</dependency> | |
<dependency> | |
<groupId>org.apache.cxf</groupId> | |
<artifactId>cxf-rt-transports-http-jetty</artifactId> | |
<version>3.1.5</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<sourceDirectory>src</sourceDirectory> | |
<plugins> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.3</version> | |
<configuration> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
<plugin> | |
<artifactId>maven-war-plugin</artifactId> | |
<version>2.6</version> | |
<configuration> | |
<warSourceDirectory>WebContent</warSourceDirectory> | |
<failOnMissingWebXml>false</failOnMissingWebXml> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment