Hallo,
I have a problem to compile the following code using gt4.2.0. This code
works in gt4.0.8. The problem is caused by method setUseNotify and
setTopicExpression from class Subscribe which are not presented in gt4.2.0.
Could you please help me to work around this problem?
Thank you, very much.
public class ValueListener implements NotifyCallback {
public void run(String serviceURI) {
try {
// The NotificationConsumerManager sets up an endpoint where
// notifications will be delivered.
NotificationConsumerManager consumer;
consumer = NotificationConsumerManager.getInstance();
consumer.startListening();
EndpointReferenceType consumerEPR = consumer
.createNotificationConsumer(this);
// Create the request to the remote Subscribe() call
Subscribe request = new Subscribe();
// Must the notification be delivered using the Notify operation?
request.setUseNotify(Boolean.TRUE); //THIS LINE CAN NOT BE USED
// Indicate what the client's EPR is
request.setConsumerReference(consumerEPR);
// The TopicExpression specifies what topic we want to subscribe to
TopicExpressionType topicExpression = new TopicExpressionType();
topicExpression.setDialect(WSNConstants.SIMPLE_TOPIC_DIALECT);
topicExpression.setValue(NotifyQNames.RP_VALUE);
NotificationProducerRP nprp = new NotificationProducerRP();
nprp.setTopicExpression(0, topicExpression);
request.setTopicExpression(topicExpression); //THIS LINE CAN NOT BE USED
// Get a reference to the NotificationProducer portType
WSBaseNotificationServiceAddressingLocator notifLocator = new
WSBaseNotificationServiceAddressingLocator();
EndpointReferenceType endpoint = new EndpointReferenceType();
endpoint.setAddress(new Address(serviceURI));
NotificationProducer producerPort = notifLocator
.getNotificationProducerPort(endpoint);
// Start the ball rolling...
SubscribeResponse response = producerPort.subscribe(request);
// We need to keep the EPR of the subscription resource so we can
// destroy it later on.
EndpointReferenceType subscriptionEPR = response
.getSubscriptionReference();
SubscriptionManagerServiceAddressingLocator subscripLocator = new
SubscriptionManagerServiceAddressingLocator();
SubscriptionManager subscripPort = subscripLocator
.getSubscriptionManagerPort(subscriptionEPR);
// Wait for key press
System.out
.println("Waiting for notification. Press any key to stop.");
System.in.read();
// Destroy the subscription port
subscripPort.destroy(new Destroy());
// Stop listening for subscriptions
consumer.stopListening();
System.out.println("Not listening anymore!");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Thank you.
Pavel