ResourceUnknownFaultType,
TopicPathDialectUnknownFaultType,
RemoteException,
MalformedURIException
{
Subscribe request = new Subscribe( );
// Create an endpoint reference for the NotificationConsumer
// Note that since we are using PortListener to handle notifications,
// rather than a Web Service that implements NotificationConsumer this
// EPR is somewhat bogus.
EndpointReferenceType epr = new EndpointReferenceType( );
epr.setAddress( new AttributedURI( callback_url ) );
epr.setPortType( new AttributedQName( "nothing" ) );
ServiceNameType snt = new ServiceNameType( );
snt.setPortName( new NCName( "NotificationConsumer" ) );
snt.set_value( new QName( "TestNotifConsumer" ) );
epr.setServiceName( snt );
// Set a couple of reference properties, including a ResourceID.
MessageElement[] prop = new MessageElement[2];
MessageElement propsResourceID =
new SOAPBodyElement( MuseAddressingConstants.REFERENCE_PROP_QNAME_RESOURCE_ID, "4444" );
prop[0] = propsResourceID;
MessageElement otherProp = new SOAPBodyElement( new QName( "http://com.xyz/props", "myprop" ),
"foo" );
prop[1] = otherProp;
ReferencePropertiesType props = new ReferencePropertiesType( );
props.set_any( prop );
epr.setReferenceProperties( props );
request.setConsumerReference( epr );
// Build the TopicExpressionType for the request.
TopicExpressionType tet = new TopicExpressionType( );
// Currently on the Simple dialect is supported.
tet.setDialect( new URI( TopicsConstants.DIALECT_TOPIC_EXPRESSION_SIMPLE ) );
tet.set_any( this.buildTopicExpressionTypeAny( propQname ) );
request.setTopicExpression( tet );
// Setup other subscription information.
Calendar terminationTime = Calendar.getInstance( );
terminationTime.add( Calendar.HOUR, 1 ); // expire this subscription in 1 hour
request.setInitialTerminationTime( terminationTime );
request.setPrecondition( new QueryExpressionType( ) );
request.setSelector( new QueryExpressionType( ) );
request.setSubscriptionPolicy( null );
// useNotify == true indicates that the Notification will be wrapped in a wsnt:Notify element.
request.setUseNotify( new Boolean( true ) );
// Issue the actual request to subscribe
SubscribeResponse response = m_stub.subscribe( request );
return response;