//create ID
Subscription ls = this.sH.create();
ls.setNotificationConsumer(notificationConsumer);
ls.setSubscriptionEndConsumer(subscriptionEndConsumer);
SubscribeDocument sdom = SubscribeDocument.Factory.newInstance();
SubscribeDocument.Subscribe s = sdom.addNewSubscribe();
//create notifyTo EPR
EndpointReferenceType nepr = (EndpointReferenceType)((XmlObjectWrapper)notificationConsumer.getEPR()).getXmlObject();
//add ReferenceProperties
ReferencePropertiesType refProps = nepr.addNewReferenceProperties();
XmlObject xmlObject = XmlBeanUtils.addChildElement( refProps, ls.getResourceKey().getName());
XmlCursor xmlCursor = xmlObject.newCursor();
xmlCursor.setTextValue(ls.getResourceKey().getValue().toString());
xmlCursor.dispose();
//notifications are send to:
DeliveryType delivery = s.addNewDelivery();
delivery.setNotifyTo(nepr);
if(UseNotify==true){
delivery.setMode(WRAPPED_MODE_URI);
}
//create endto EPR
EndpointReferenceType eepr = (EndpointReferenceType)((XmlObjectWrapper)subscriptionEndConsumer.getEPR()).getXmlObject();
//add ReferenceProperties we already created
eepr.setReferenceProperties(refProps);
//subscription ends are send to:
s.setEndTo(eepr);
//TODO check Calendar serializing
ExpirationType expires = ExpirationType.Factory.newInstance();
expires.setObjectValue(initialTerminationTime);
s.setExpires(expires);
//TODO multiple filters
//XPathFilter
if(xf!=null){
FilterType filter = s.addNewFilter();
java.net.URI uri = xf.getURI();
if(uri!=null)
filter.setDialect(uri.toString());
filter.newCursor().setTextValue((String)xf.getExpression());
}
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 = EnvelopeDocument.Factory.parse(new java.io.ByteArrayInputStream(os.toByteArray()));