WebService Client over JMS For TIBCO EMS

Environment

TIBCO 5.8

JDK 1.6

Dependency

TIBCOjms.jar 5.8

cxf-rt-transports-jms 3.0.9

Process

Step 1. Refer to eclipse-juno-maven-cxf-generate-webservice-client to generate WebService Client

Step 2. Using TibjmsQueueConnectionFactory. Must use the correct ConnectionFactory; otherwise, an exception like “Cannot send, channel has already failed: ……” will occur.

TibjmsQueueConnectionFactory cf = new TibjmsQueueConnectionFactory("tcp://[EMS IP]:[Port]");

JaxWsProxyFactoryBean client = new JaxWsProxyFactoryBean();
client.setAddress("jms://");

XXXPortType port = client.create(XXXPortType.class);

Client cproxy = ClientProxy.getClient(port);
JMSConduit conduit = (JMSConduit) cproxy.getConduit();
JMSConfiguration config = conduit.getJmsConfig();
config.setTargetDestination([Queue Name]);
config.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
config.setMessageType(JMSConstants.TEXT_MESSAGE_TYPE);
config.setRequestURI(null);

config.setConnectionFactory(cf);

Step 3. Setting “SoapAction” JMS property. TIBCO uses “SoapAction” property to dispatch the request to the correct service; therefore, MUST set this property.

// JMS Customized Properties
Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();

JMSMessageHeadersType jmsHeader = new JMSMessageHeadersType();

// TIBCO 是以 SoapAction 決定由何 Service 接收此 Request, 因此必需自定此 Header
JMSPropertyType propType = new JMSPropertyType();
propType.setName("SoapAction");
propType.setValue([TIBCO WSDL 中 JMS Binding soapAction 的值]);
jmsHeader.getProperty().add(propType);

requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, jmsHeader);

XXXRequest req = new XXXRequest();
......
XXXResponse resp = port.operator(req);

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s