? I am using CXF with Spring to publish and use my WebServices in JBoss 5.1 . Everything is working fi...">

Is there any annotation <jaxws: endpoint / ">?

I am using CXF with Spring to publish and use my WebServices in JBoss 5.1 . Everything is working fine.

However, it seems very tedious to me: put the jaxws: endpoint tag for each WebService in applicationContext.xml .

There is no way to do this with annotations? Thanks to everyone.

+4
source share
2 answers

There are some annotations to tweak what you can also put in <jaxws:endpoint> . Annotations for announcing the CXF endpoint will be nice.

You can configure the endpoint using code instead of Spring XML. This can be convenient if you have a lot of duplicate configurations that you can exclude. Or, if you have specific endpoints configured differently in different environments.

For instance:

 @Autowired var authImpl: Auth = _ @Autowired var faultListener: FaultListener = _ def initWebServices() { var sf: JaxWsServerFactoryBean = _ val propMap = mutable.HashMap[String, AnyRef]("org.apache.cxf.logging.FaultListener"->faultListener.asInstanceOf[AnyRef]) sf = new JaxWsServerFactoryBean sf.setServiceBean(authImpl) sf.setAddress("/auth") sf.setServiceName(new QName("http://auth.ws.foo.com/", "auth", "AuthService")) sf.setProperties(propMap) sf.create // more services... 
+2
source

Over time, new opportunities arise.

Working with CXF / SpringBoot (SpringBoot: 1.2.3, CXF: 3.10, Spring: 4.1.6) is a good alternative to get rid of the jaxws: endpoint configuration in cxf-servlet.xml, as jonashackt pointed out in nabble.com . However, this solution is only possible if the application has only one endpoint (at least I was unable to configure more than one).

 public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean public ServletRegistrationBean dispatcherServlet() { CXFServlet cxfServlet = new CXFServlet(); return new ServletRegistrationBean(cxfServlet, "/api/*"); } @Bean(name="cxf") public SpringBus springBus() { return new SpringBus(); } @Bean public MyServicePortType myService() { return new MyServiceImpl(); } @Bean public Endpoint endpoint() { EndpointImpl endpoint = new EndpointImpl(springBus(), myService()); endpoint.publish("/MyService"); return endpoint; } 

Where MyServicePortType is a class with @WebService annotation. This endpoint is then called for a URL such as "localhost: 8080 / api / MyService"

Of course, these @ Bean declarations can be placed in any other spring configuration class.

In contrast to the copied original solution, I suggest creating a bus instance (cxf-Bean) using the factory method instead of the direct "new SpringBus ()":

 BusFactory.newInstance().createBus() 
+1
source

Source: https://habr.com/ru/post/1347287/


All Articles