/** * Add wsa:From SOAP header to the message * @param sh - the SOAP header for the message * @param fromEPR - the (Axis2) EPR to include in the wsa:From * @throws AxisFault - if an error occurs setting the wsa:From into the header */ private void addWSAFromHeader( SOAPHeader sh, EndpointReference fromEPR ) throws AxisFault { OMElement epr = EndpointReferenceHelper.toOM(sh.getOMFactory(), fromEPR, QNAME_WSA_FROM, AddressingConstants.Final.WSA_NAMESPACE); sh.addChild(epr); } // end method addWSAFromHeader
public static String getBrokerPublishEPR(String brokerURL, String topic) { brokerURL = WorkFlowUtils.formatURLString(brokerURL); EndpointReference encodedEpr = WSEProtocolClient.createEndpointReference(brokerURL, topic); String ret = null; try { OMElement eprCrEl = EndpointReferenceHelper.toOM(OMAbstractFactory.getOMFactory(), encodedEpr, new QName( "EndpointReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); ret = eprCrEl.toStringWithConsume(); } catch (Exception e) { logger.error("unable to convert broker url", e); } return ret; /* * String epr = null; brokerURL = WorkFlowUtils.formatURLString(brokerURL); if (brokerURL.endsWith("/")) { epr = * brokerURL + STRING_TOPIC + topic; } else { epr = brokerURL + "/" + STRING_TOPIC + topic; } * * epr = "<wsa:EndpointReference " + "xmlns:wsa='http://www.w3.org/2005/08/addressing'>" + "<wsa:Address>" + epr * + "</wsa:Address>" + "</wsa:EndpointReference>"; return epr; */ } }
private OMElement createMessageEl(EndpointReference eventSinkReferenceEPR, OMElement filterEl, long expireTime) throws AxisFault { OMElement message = factory.createOMElement("Subscribe", NameSpaceConstants.WSE_NS); OMElement delivery = factory.createOMElement("Delivery", NameSpaceConstants.WSE_NS); OMElement expires = factory.createOMElement("Expires", NameSpaceConstants.WSE_NS); expires.setText(Long.toString(expireTime)); message.addChild(expires); OMElement notifyTo = EndpointReferenceHelper.toOM(factory, eventSinkReferenceEPR, new QName( NameSpaceConstants.WSE_NS.getNamespaceURI(), "NotifyTo"), NameSpaceConstants.WSA_NS.getNamespaceURI()); delivery.addChild(notifyTo); message.addChild(delivery); if (filterEl != null) { message.addChild(filterEl); } message.declareNamespace(NameSpaceConstants.WSA_NS); return message; }
private OMElement createMessageEl(EndpointReference eventSinkReferenceEPR, OMElement filterEl, long expireTime) throws AxisFault { OMElement message = factory.createOMElement("Subscribe", NameSpaceConstants.WSE_NS); OMElement delivery = factory.createOMElement("Delivery", NameSpaceConstants.WSE_NS); OMElement expires = factory.createOMElement("Expires", NameSpaceConstants.WSE_NS); expires.setText(Long.toString(expireTime)); message.addChild(expires); OMElement notifyTo = EndpointReferenceHelper.toOM(factory, eventSinkReferenceEPR, new QName( NameSpaceConstants.WSE_NS.getNamespaceURI(), "NotifyTo"), NameSpaceConstants.WSA_NS.getNamespaceURI()); delivery.addChild(notifyTo); message.addChild(delivery); if (filterEl != null) { message.addChild(filterEl); } message.declareNamespace(NameSpaceConstants.WSA_NS); return message; }
/** * Convert MetadatReference object content to the OMElement representation. * @return OMElement representation of MetadatReference. * @throws MexOMException */ public OMElement toOM() throws MexOMException { if (eprElement == null) { throw new MexOMException( "Must have EndpointReference element in MetadataReference"); } OMElement metadataRef = null; try { metadataRef = EndpointReferenceHelper.toOM(factory, epr, new QName( namespaceValue, MexConstants.SPEC.METADATA_REFERENCE, MexConstants.SPEC.NS_PREFIX), eprElement.getNamespace() .getNamespaceURI()); } catch (AxisFault e) { throw new MexOMException(e); } return metadataRef; }
public OMElement toOMElement(OMElement element) throws OMException,AxisFault { if (epr == null) throw new OMException(SandeshaMessageHelper.getMessage( SandeshaMessageKeys.cannotSetAcksTo, null)); OMFactory factory = element.getOMFactory(); QName acksTo = new QName (rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.ACKS_TO, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM); OMElement endpointElement = EndpointReferenceHelper.toOM (factory,epr, acksTo ,addressingNamespaceValue); element.addChild(endpointElement); return element; }
public OMElement toOMElement(OMElement element) throws OMException,AxisFault { if (epr == null) throw new OMException(SandeshaMessageHelper.getMessage( SandeshaMessageKeys.cannotSetEndpoint, null)); OMFactory factory = element.getOMFactory(); QName endpoint = new QName (rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.ENDPOINT, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM); OMElement endpointElement = EndpointReferenceHelper.toOM (factory, epr, endpoint, addressingNamespaceValue); element.addChild(endpointElement); return element; }
public static OMElement createSubscription(EndpointReference eventSink, String topicExpression, String xpathExpression, long expireTime) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement subscribeMsg = factory.createOMElement("Subscribe", NameSpaceConstants.WSE_NS); OMElement delivery = factory.createOMElement("Delivery", NameSpaceConstants.WSE_NS); OMElement expires = factory.createOMElement("Expires", NameSpaceConstants.WSE_NS); expires.setText(Long.toString(expireTime)); subscribeMsg.addChild(expires); OMElement notifyTo = EndpointReferenceHelper.toOM(factory, eventSink, new QName(NameSpaceConstants.WSE_NS.getNamespaceURI(), "NotifyTo"), NameSpaceConstants.WSA_NS.getNamespaceURI()); delivery.addChild(notifyTo); subscribeMsg.addChild(delivery); OMElement filterEl = createFilter(topicExpression, xpathExpression); if (filterEl != null) { subscribeMsg.addChild(filterEl); } subscribeMsg.declareNamespace(NameSpaceConstants.WSA_NS); return subscribeMsg; }
public static OMElement createSubscription(EndpointReference eventSink, String topicExpression, String xpathExpression, long expireTime) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement subscribeMsg = factory.createOMElement("Subscribe", NameSpaceConstants.WSE_NS); OMElement delivery = factory.createOMElement("Delivery", NameSpaceConstants.WSE_NS); OMElement expires = factory.createOMElement("Expires", NameSpaceConstants.WSE_NS); expires.setText(Long.toString(expireTime)); subscribeMsg.addChild(expires); OMElement notifyTo = EndpointReferenceHelper.toOM(factory, eventSink, new QName(NameSpaceConstants.WSE_NS.getNamespaceURI(), "NotifyTo"), NameSpaceConstants.WSA_NS.getNamespaceURI()); delivery.addChild(notifyTo); subscribeMsg.addChild(delivery); OMElement filterEl = createFilter(topicExpression, xpathExpression); if (filterEl != null) { subscribeMsg.addChild(filterEl); } subscribeMsg.declareNamespace(NameSpaceConstants.WSA_NS); return subscribeMsg; }
public WsrfResourceStub registerPublisher(EndpointReference omEndpointReference) throws AxisFault { // invoker.setMessageId(null); OMElement message = factory.createOMElement(new QName(NameSpaceConstants.WSBR_NS.getNamespaceURI(), "RegisterPublisher")); // builder.newFragment(WsmgConstants.WSBR_NS, // "RegisterPublisher"); // EndpointReference publisherRef; OMElement publisherRef = null; publisherRef = EndpointReferenceHelper.toOM(factory, omEndpointReference, new QName(NameSpaceConstants.WSBR_NS.getNamespaceURI(), "PublisherReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); message.addChild(publisherRef); ServiceClient client = createServiceClient(message); OMElement responseMessage = client.sendReceive(message); client.cleanupTransport(); OMElement publisherRegistrationRef = responseMessage.getFirstChildWithName(new QName(NameSpaceConstants.WSBR_NS .getNamespaceURI(), "PublisherRegistrationReference")); EndpointReference epr = EndpointReferenceHelper.fromOM(publisherRegistrationRef); return new WsrfResourceStub(epr, getTimeoutInMilliSeconds()); }
public WsrfResourceStub registerPublisher(EndpointReference omEndpointReference) throws AxisFault { // invoker.setMessageId(null); OMElement message = factory.createOMElement(new QName(NameSpaceConstants.WSBR_NS.getNamespaceURI(), "RegisterPublisher")); // builder.newFragment(WsmgConstants.WSBR_NS, // "RegisterPublisher"); // EndpointReference publisherRef; OMElement publisherRef = null; publisherRef = EndpointReferenceHelper.toOM(factory, omEndpointReference, new QName(NameSpaceConstants.WSBR_NS.getNamespaceURI(), "PublisherReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); message.addChild(publisherRef); ServiceClient client = createServiceClient(message); OMElement responseMessage = client.sendReceive(message); client.cleanup(); client.cleanupTransport(); OMElement publisherRegistrationRef = responseMessage.getFirstChildWithName(new QName(NameSpaceConstants.WSBR_NS .getNamespaceURI(), "PublisherRegistrationReference")); EndpointReference epr = EndpointReferenceHelper.fromOM(publisherRegistrationRef); return new WsrfResourceStub(epr, getTimeoutInMilliSeconds()); }
public void createSubscribeResponse(ProcessingContext ctx, String subId) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); ctx.addResponseMsgNameSpaces(NameSpaceConstants.WSNT_NS); OMElement responseMessage = factory.createOMElement("SubscribeResponse", NameSpaceConstants.WSNT_NS); OMElement identifier = factory.createOMElement(WsmgCommonConstants.SUBSCRIPTION_ID, responseMessage.getNamespace()); identifier.setText(subId); EndpointReference serviceLocationEndpointReference = new EndpointReference(ctx.getMessageContext() .getAxisService().getEndpointURL()); serviceLocationEndpointReference.addReferenceParameter(identifier); OMElement subscriptionReference = null; try { subscriptionReference = EndpointReferenceHelper.toOM(factory, serviceLocationEndpointReference, new QName( "SubscriptionReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); responseMessage.addChild(subscriptionReference); subscriptionReference.setNamespace(responseMessage.getNamespace()); } catch (AxisFault e) { log.error("unable to resolve EPR from OM", e); throw e; } ctx.setRespMessage(responseMessage); }
public static OMElement encodeNotification(String topic, OMElement message, EndpointReference producerReference) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement topicExpEl = factory.createOMElement("Topic", NameSpaceConstants.WSNT_NS); topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null); topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topic); OMElement messageToNotify = factory.createOMElement("Notify", NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSA_NS); OMElement notificationMesssageEl = factory.createOMElement("NotificationMessage", messageToNotify.getNamespace(), messageToNotify); notificationMesssageEl.addChild(topicExpEl); notificationMesssageEl.addChild(EndpointReferenceHelper.toOM(factory, producerReference, new QName( notificationMesssageEl.getNamespace().getNamespaceURI(), "ProducerReference", notificationMesssageEl.getNamespace().getPrefix()), NameSpaceConstants.WSA_NS.getNamespaceURI())); OMElement messageEl = factory.createOMElement("Message", notificationMesssageEl.getNamespace(), notificationMesssageEl); messageEl.addChild(message); return messageToNotify; }
public static OMElement createSubscriptionMsg(EndpointReference eventSinkLocation, String topicExpression, String xpathExpression) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement message = factory.createOMElement("SubscribeRequest", NameSpaceConstants.WSNT_NS); if (topicExpression != null) { OMElement topicExpEl = factory.createOMElement("TopicExpression", NameSpaceConstants.WSNT_NS, message); topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, NameSpaceConstants.WSNT_NS); topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topicExpression); } if (xpathExpression != null) { OMElement xpathExpEl = factory.createOMElement("Selector", NameSpaceConstants.WSNT_NS, message); xpathExpEl.addAttribute("Dialect", WsmgCommonConstants.XPATH_DIALECT, null); xpathExpEl.setText(xpathExpression); } OMElement useNotifyEl = factory.createOMElement("UseNotify", message.getNamespace(), message); useNotifyEl.setText("true");// check wether we still need this OMElement eprCrEl = EndpointReferenceHelper.toOM(factory, eventSinkLocation, new QName("ConsumerReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); message.addChild(eprCrEl); eprCrEl.setNamespace(message.getNamespace()); return message; }
public static OMElement createSubscriptionMsg(EndpointReference eventSinkLocation, String topicExpression, String xpathExpression) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement message = factory.createOMElement("SubscribeRequest", NameSpaceConstants.WSNT_NS); if (topicExpression != null) { OMElement topicExpEl = factory.createOMElement("TopicExpression", NameSpaceConstants.WSNT_NS, message); topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, NameSpaceConstants.WSNT_NS); topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topicExpression); } if (xpathExpression != null) { OMElement xpathExpEl = factory.createOMElement("Selector", NameSpaceConstants.WSNT_NS, message); xpathExpEl.addAttribute("Dialect", WsmgCommonConstants.XPATH_DIALECT, null); xpathExpEl.setText(xpathExpression); } OMElement useNotifyEl = factory.createOMElement("UseNotify", message.getNamespace(), message); useNotifyEl.setText("true");// check wether we still need this OMElement eprCrEl = EndpointReferenceHelper.toOM(factory, eventSinkLocation, new QName("ConsumerReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); message.addChild(eprCrEl); eprCrEl.setNamespace(message.getNamespace()); return message; }
public static OMElement createSubscriptionMsg(EndpointReference eventSinkLocation, String topicExpression, String xpathExpression) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement message = factory.createOMElement("SubscribeRequest", NameSpaceConstants.WSNT_NS); if (topicExpression != null) { OMElement topicExpEl = factory.createOMElement("TopicExpression", NameSpaceConstants.WSNT_NS, message); topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, NameSpaceConstants.WSNT_NS); topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topicExpression); } if (xpathExpression != null) { OMElement xpathExpEl = factory.createOMElement("Selector", NameSpaceConstants.WSNT_NS, message); xpathExpEl.addAttribute("Dialect", WsmgCommonConstants.XPATH_DIALECT, null); xpathExpEl.setText(xpathExpression); } OMElement useNotifyEl = factory.createOMElement("UseNotify", message.getNamespace(), message); useNotifyEl.setText("true");// check wether we still need this OMElement eprCrEl = EndpointReferenceHelper.toOM(factory, eventSinkLocation, new QName("ConsumerReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); message.addChild(eprCrEl); eprCrEl.setNamespace(message.getNamespace()); return message; }
public static OMElement encodeNotification(String topic, OMElement message, EndpointReference producerReference) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement topicExpEl = factory.createOMElement("Topic", NameSpaceConstants.WSNT_NS); topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null); topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topic); OMElement messageToNotify = factory.createOMElement("Notify", NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSA_NS); OMElement notificationMesssageEl = factory.createOMElement("NotificationMessage", messageToNotify.getNamespace(), messageToNotify); notificationMesssageEl.addChild(topicExpEl); notificationMesssageEl.addChild(EndpointReferenceHelper.toOM(factory, producerReference, new QName( notificationMesssageEl.getNamespace().getNamespaceURI(), "ProducerReference", notificationMesssageEl.getNamespace().getPrefix()), NameSpaceConstants.WSA_NS.getNamespaceURI())); OMElement messageEl = factory.createOMElement("Message", notificationMesssageEl.getNamespace(), notificationMesssageEl); messageEl.addChild(message); return messageToNotify; }
public static OMElement encodeNotification(String topic, OMElement message, EndpointReference producerReference) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement topicExpEl = factory.createOMElement("Topic", NameSpaceConstants.WSNT_NS); topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null); topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topic); OMElement messageToNotify = factory.createOMElement("Notify", NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSA_NS); OMElement notificationMesssageEl = factory.createOMElement("NotificationMessage", messageToNotify.getNamespace(), messageToNotify); notificationMesssageEl.addChild(topicExpEl); notificationMesssageEl.addChild(EndpointReferenceHelper.toOM(factory, producerReference, new QName( notificationMesssageEl.getNamespace().getNamespaceURI(), "ProducerReference", notificationMesssageEl .getNamespace().getPrefix()), NameSpaceConstants.WSA_NS.getNamespaceURI())); OMElement messageEl = factory.createOMElement("Message", notificationMesssageEl.getNamespace(), notificationMesssageEl); messageEl.addChild(message); return messageToNotify; }
public void createSubscribeResponse(ProcessingContext ctx, String subId) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); ctx.addResponseMsgNameSpaces(NameSpaceConstants.WSNT_NS); OMElement responseMessage = factory.createOMElement("SubscribeResponse", NameSpaceConstants.WSNT_NS); OMElement identifier = factory.createOMElement(WsmgCommonConstants.SUBSCRIPTION_ID, responseMessage.getNamespace()); identifier.setText(subId); EndpointReference serviceLocationEndpointReference = new EndpointReference(ctx.getMessageContext() .getAxisService().getEndpointURL()); serviceLocationEndpointReference.addReferenceParameter(identifier); OMElement subscriptionReference = null; try { subscriptionReference = EndpointReferenceHelper.toOM(factory, serviceLocationEndpointReference, new QName( "SubscriptionReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); responseMessage.addChild(subscriptionReference); subscriptionReference.setNamespace(responseMessage.getNamespace()); } catch (AxisFault e) { log.error("unable to resolve EPR from OM", e); throw e; } ctx.setRespMessage(responseMessage); }
public static OMElement encodeNotification(String topic, OMElement message, EndpointReference producerReference) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement topicExpEl = factory.createOMElement("Topic", NameSpaceConstants.WSNT_NS); topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null); topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topic); OMElement messageToNotify = factory.createOMElement("Notify", NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSNT_NS); messageToNotify.declareNamespace(NameSpaceConstants.WSA_NS); OMElement notificationMesssageEl = factory.createOMElement("NotificationMessage", messageToNotify.getNamespace(), messageToNotify); notificationMesssageEl.addChild(topicExpEl); notificationMesssageEl.addChild(EndpointReferenceHelper.toOM(factory, producerReference, new QName( notificationMesssageEl.getNamespace().getNamespaceURI(), "ProducerReference", notificationMesssageEl .getNamespace().getPrefix()), NameSpaceConstants.WSA_NS.getNamespaceURI())); OMElement messageEl = factory.createOMElement("Message", notificationMesssageEl.getNamespace(), notificationMesssageEl); messageEl.addChild(message); return messageToNotify; }