Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: CXF-2970

...

Code Block
xml
xml
<wsdl:definitions name="JMSGreeterService"
	<wsdl:binding name="JMSGreeterPortBinding" type="tns:JMSGreeterPortType">
		<soap:binding style="document"
			transport="http://www.w3.org/20082010/07/soap/bindings/JMS/soapjms/" />
		<soapjms:jndiContextParameter name="name"
			value="value" />
		<soapjms:jndiConnectionFactoryName>ConnectionFactory
		</soapjms:jndiConnectionFactoryName>
		<soapjms:jndiInitialContextFactory>
			org.apache.activemq.jndi.ActiveMQInitialContextFactory
		</soapjms:jndiInitialContextFactory>
		<soapjms:jndiURL>tcp://localhost:61616
		</soapjms:jndiURL>
		<soapjms:deliveryMode>PERSISTENT</soapjms:deliveryMode>
		<soapjms:priority>5</soapjms:priority>
		<soapjms:timeToLive>1000</soapjms:timeToLive>
		<wsdl:operation name="greetMe">
			<soap:operation soapAction="test" style="document" />
			<wsdl:input name="greetMeRequest">
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output name="greetMeResponse">
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	        <wsdl:service name="JMSGreeterService">
		<soapjms:jndiConnectionFactoryName>ConnectionFactory
		</soapjms:jndiConnectionFactoryName>
		<soapjms:jndiInitialContextFactory>
			org.apache.activemq.jndi.ActiveMQInitialContextFactory
		</soapjms:jndiInitialContextFactory>
		<wsdl:port binding="tns:JMSGreeterPortBinding" name="GreeterPort">
			<soap:address location="jms:jndi:dynamicQueues/test.cxf.jmstransport.queue" />
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>

...

Code Block
java
java
        // 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: Before you start the server, you need to make sure the JMS broker is stared, you can find some useful code of starting the JMS broker here.

Wiki Markup
{snippet:id=broker|lang=java|url=cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java}

Consume the service with the API

...