Publishing a service with the JAVA API - 8.0

Talend ESB Service Developer Guide

Version
8.0
Language
English
Product
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend ESB
Talend Runtime
Content
Design and Development
Installation and Upgrade
Last publication date
2023-11-06

Developers who don't wish to modify the WSDL file can also publish the endpoint information using Java code. For CXF's SOAP over JMS implementation you can write the following:

// You just need to set the address with JMS URI
String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3"
   + "?jndiInitialContextFactory"
   + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
   + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL" 
   + "=tcp://localhost:61500";
Hello implementor = new HelloImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(Hello.class);
svrFactory.setAddress(address);
// And specify the transport ID with SOAP over JMS specification
svrFactory.setTransportId(
   JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
svrFactory.setServiceBean(implementor);
svrFactory.create();

NOTE: For tests it can be useful to create an embedded broker like this:

public final void run() {
    try {            
         broker = new BrokerService();
         broker.setPersistent(false);
         broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
         broker.setTmpDataDirectory(new File("./target"));
         broker.setUseJmx(false);
         if (brokerName != null) {
             broker.setBrokerName(brokerName);
         }        broker.addConnector(brokerUrl1);
         broker.start();
    } catch (Exception e) {
         e.printStackTrace();
    }
}