TopicFilter tf,
XPathFilter xf,
Calendar initialTerminationTime,
boolean UseNotify )
{
SubscribeDocument sdom = SubscribeDocument.Factory.newInstance( );
SubscribeDocument.Subscribe s = sdom.addNewSubscribe( );
//subscription ends are send to:
//TODO
//notifications are send to:
s.setConsumerReference( (org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType) ( (XmlObjectWrapper) notificationConsumer
.getEPR( ) )
.getXmlObject( ) );
//TODO check Calendar serializing
s.setInitialTerminationTime( initialTerminationTime );
//TODO multiple filters
if ( tf != null )
{
TopicExpressionType te = s.addNewTopicExpression( );
XmlCursor xc = te.newCursor( );
xc.toNextToken( );
xc.insertNamespace( "tns",
tf.getNameSpace( ) );
te.newCursor( ).setTextValue( (String) tf.getExpression( ) );
te.setDialect( tf.getURI( ).toString( ) );
}
//create Subscription
//add to local SubscriptionHome
org.apache.ws.notification.pubsub.Subscription ls = this.sH.create( );
SubscribeResponseDocument.SubscribeResponse sresres = null;
try
{
//now call
wsaSOAPConnection sconn = wsaSOAPConnection.newInstance( );
MessageFactory mf = MessageFactory.newInstance( );
SOAPMessage soapm = mf.createMessage( );
//put XMLbean into SOAPBody
soapm.getSOAPBody( ).addDocument( (org.w3c.dom.Document) sdom.newDomNode( ) );
SOAPMessage subscribeResponse = sconn.call( soapm,
epr.getAddress( ).toString( ) );
java.io.ByteArrayOutputStream os = new java.io.ByteArrayOutputStream( );
subscribeResponse.writeTo( os );
EnvelopeDocument sres =