File tree Expand file tree Collapse file tree
java/com/baeldung/cxf/spring
test/java/com/baeldung/cxf/spring Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ target /
Original file line number Diff line number Diff line change 1919 <artifactId >maven-war-plugin</artifactId >
2020 <version >2.6</version >
2121 <configuration >
22- <webXml >src/main/webapp/WEB-INF/web.xml</ webXml >
22+ <failOnMissingWebXml >false</ failOnMissingWebXml >
2323 </configuration >
2424 </plugin >
2525 <plugin >
110110 </dependency >
111111 <dependency >
112112 <groupId >org.springframework</groupId >
113- <artifactId >spring-web </artifactId >
113+ <artifactId >spring-webmvc </artifactId >
114114 <version >${spring.version} </version >
115115 </dependency >
116+ <dependency >
117+ <groupId >javax.servlet</groupId >
118+ <artifactId >javax.servlet-api</artifactId >
119+ <version >3.1.0</version >
120+ </dependency >
116121 </dependencies >
117122</project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .cxf .spring ;
2+
3+ import javax .servlet .ServletContext ;
4+ import javax .servlet .ServletRegistration ;
5+
6+ import org .apache .cxf .transport .servlet .CXFServlet ;
7+ import org .springframework .web .WebApplicationInitializer ;
8+ import org .springframework .web .context .ContextLoaderListener ;
9+ import org .springframework .web .context .support .AnnotationConfigWebApplicationContext ;
10+
11+ public class AppInitializer implements WebApplicationInitializer {
12+ @ Override
13+ public void onStartup (ServletContext container ) {
14+ AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext ();
15+ context .register (ServiceConfiguration .class );
16+ container .addListener (new ContextLoaderListener (context ));
17+
18+ ServletRegistration .Dynamic dispatcher = container .addServlet ("dispatcher" , new CXFServlet ());
19+ dispatcher .addMapping ("/services" );
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .cxf .spring ;
2+
3+ import org .apache .cxf .jaxws .JaxWsProxyFactoryBean ;
4+ import org .springframework .context .annotation .Bean ;
5+ import org .springframework .context .annotation .Configuration ;
6+
7+ @ Configuration
8+ public class ClientConfiguration {
9+ @ Bean (name = "client" )
10+ public Object generateProxy () {
11+ return proxyFactoryBean ().create ();
12+ }
13+
14+ @ Bean
15+ public JaxWsProxyFactoryBean proxyFactoryBean () {
16+ JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean ();
17+ proxyFactory .setServiceClass (Baeldung .class );
18+ proxyFactory .setAddress ("http://localhost:8080/services/baeldung" );
19+ return proxyFactory ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .cxf .spring ;
2+
3+ import javax .xml .ws .Endpoint ;
4+
5+ import org .apache .cxf .Bus ;
6+ import org .apache .cxf .bus .spring .SpringBus ;
7+ import org .apache .cxf .jaxws .EndpointImpl ;
8+ import org .springframework .context .annotation .Bean ;
9+ import org .springframework .context .annotation .Configuration ;
10+
11+ @ Configuration
12+ public class ServiceConfiguration {
13+ @ Bean (name = Bus .DEFAULT_BUS_ID )
14+ public SpringBus springBus () {
15+ return new SpringBus ();
16+ }
17+
18+ @ Bean
19+ public Endpoint endpoint () {
20+ EndpointImpl endpoint = new EndpointImpl (springBus (), new BaeldungImpl ());
21+ endpoint .publish ("http://localhost:8080/services/baeldung" );
22+ return endpoint ;
23+ }
24+ }
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 33import static org .junit .Assert .assertEquals ;
44
55import org .junit .Test ;
6- import org .springframework .context .support .ClassPathXmlApplicationContext ;
6+ import org .springframework .context .ApplicationContext ;
7+ import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
78
89public class StudentTest {
9- private ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext (new String [] { "client-beans.xml" });
10- private Baeldung baeldungProxy ;
11-
12- {
13- baeldungProxy = (Baeldung ) context .getBean ("client" );
14- }
10+ private ApplicationContext context = new AnnotationConfigApplicationContext (ClientConfiguration .class );
11+ private Baeldung baeldungProxy = (Baeldung ) context .getBean ("client" );
1512
1613 @ Test
1714 public void whenUsingHelloMethod_thenCorrect () {
You can’t perform that action at this time.
0 commit comments