Author: asankaa
Date: Sun Nov 23 12:15:04 2008
New Revision: 24634
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=24634

Log:
unsubscribe responce message and wsa:Action set to the responces 


Modified:
   
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventSource.java
   
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/ResponseMessageBuilder.java

Modified: 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventSource.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventSource.java?rev=24634&r1=24633&r2=24634&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventSource.java
 (original)
+++ 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventSource.java
 Sun Nov 23 12:15:04 2008
@@ -105,11 +105,13 @@
             String replyAddress = mc.getOptions().getReplyTo().getAddress();
             AddressEndpoint endpoint = new AddressEndpoint();
             EndpointDefinition def = new EndpointDefinition();
-            def.setAddress(replyAddress.trim());
+            def.setAddress(replyAddress.trim());            
             endpoint.setDefinition(def);
             org.apache.synapse.MessageContext rmc = new 
Axis2MessageContext(mc, synCfg, synEnv);
-            rmc.setTo(new EndpointReference(replyAddress));
             rmc.setEnvelope(soapEnvelope);
+            rmc.setTo(new EndpointReference(replyAddress));
+            rmc.setSoapAction(EventingConstants.WSE_SUbSCRIBE_RESPONSE);
+            rmc.setWSAAction(EventingConstants.WSE_SUbSCRIBE_RESPONSE);
             endpoint.send(MessageHelper.cloneMessageContext(rmc));
         } else if 
(EventingConstants.WSE_UNSUBSCRIBE.equals(mc.getWSAAction())) {
             // Unsubscribe for responce

Modified: 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/ResponseMessageBuilder.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/ResponseMessageBuilder.java?rev=24634&r1=24633&r2=24634&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/ResponseMessageBuilder.java
     (original)
+++ 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/ResponseMessageBuilder.java
     Sun Nov 23 12:15:04 2008
@@ -1,19 +1,18 @@
 package org.apache.synapse.eventing.builders;
 
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.synapse.eventing.Subscription;
-import org.apache.synapse.SynapseException;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.EndpointReferenceHelper;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.eventing.Subscription;
 import org.wso2.eventing.EventingConstants;
 
 import javax.xml.namespace.QName;
@@ -39,40 +38,75 @@
 public class ResponseMessageBuilder {
     private SOAPFactory factory;
     private static final Log log = 
LogFactory.getLog(ResponseMessageBuilder.class);
-    public ResponseMessageBuilder(MessageContext messageCtx){
+
+    public ResponseMessageBuilder(MessageContext messageCtx) {
         factory = (SOAPFactory) messageCtx.getEnvelope().getOMFactory();
         //factory =(SOAPFactory) OMAbstractFactory.getOMFactory();
     }
 
     /**
+     * (01) <s12:Envelope
+     * (02)     xmlns:s12="http://www.w3.org/2003/05/soap-envelope";
+     * (03)     xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing";
+     * (04)     xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing";
+     * (05)     xmlns:ew="http://www.example.com/warnings";
+     * (06)     xmlns:ow="http://www.example.org/oceanwatch"; >
+     * (07)   <s12:Header>
+     * (08)     <wsa:Action>
+     * (09) http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse
+     * (10)     </wsa:Action>
+     * (11)     <wsa:RelatesTo>
+     * (12)       uuid:e1886c5c-5e86-48d1-8c77-fc1c28d47180
+     * (13)     </wsa:RelatesTo>
+     * (14)     <wsa:To>http://www.example.com/MyEventSink</wsa:To>
+     * (15)     <ew:MySubscription>2597</ew:MySubscription>
+     * (16)   </s12:Header>
+     * (17)   <s12:Body>
+     * (18)     <wse:SubscribeResponse>
+     * (19)       <wse:SubscriptionManager>
+     * (20)         <wsa:Address>
+     * (21)           http://www.example.org/oceanwatch/SubscriptionManager
+     * (22)         </wsa:Address>
+     * (23)         <wsa:ReferenceParameters>
+     * (24)           <wse:Identifier>
+     * (25)             uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa
+     * (26)           </wse:Identifier>
+     * (27)         </wsa:ReferenceParameters>
+     * (28)       </wse:SubscriptionManager>
+     * (29)       <wse:Expires>2004-07-01T00:00:00.000-00:00</wse:Expires>
+     * (30)     </wse:SubscribeResponse>
+     * (31)   </s12:Body>
+     * (32) </s12:Envelope>
      * Generate the subscription responce message
+     *
      * @param subscription
      * @return
      */
-    public SOAPEnvelope genSubscriptionResponse(Subscription subscription){
+    public SOAPEnvelope genSubscriptionResponse(Subscription subscription) {
         SOAPEnvelope message = factory.getDefaultEnvelope();
         EndpointReference subscriptionManagerEPR = new 
EndpointReference("http://localhost:8280/soap/eventing";); //TODO: add 
subscription url to subscription object
         subscriptionManagerEPR.addReferenceParameter(new 
QName(EventingConstants.WSE_EVENTING_NS,
-                EventingConstants.WSE_EN_IDENTIFIER, 
EventingConstants.WSE_EVENTING_PREFIX),subscription.getId());
+                EventingConstants.WSE_EN_IDENTIFIER, 
EventingConstants.WSE_EVENTING_PREFIX), subscription.getId());
         OMNamespace eventingNamespace = 
factory.createOMNamespace(EventingConstants.WSE_EVENTING_NS,
-                                                    
EventingConstants.WSE_EVENTING_PREFIX);
+                EventingConstants.WSE_EVENTING_PREFIX);
         OMElement subscribeResponseElement = 
factory.createOMElement(EventingConstants.WSE_EN_SUBSCRIBE_RESPONSE, 
eventingNamespace);
         try {
             OMElement subscriptionManagerElement = 
EndpointReferenceHelper.toOM(
-                        subscribeResponseElement.getOMFactory(),
-                        subscriptionManagerEPR,
-                        new QName(EventingConstants.WSE_EVENTING_NS,
-                                  
EventingConstants.WSE_EN_SUBSCRIPTION_MANAGER,
-                                  EventingConstants.WSE_EVENTING_PREFIX),
-                        AddressingConstants.Submission.WSA_NAMESPACE);
-                subscribeResponseElement.addChild(subscriptionManagerElement);
-                message.getBody().addChild(subscribeResponseElement);
+                    subscribeResponseElement.getOMFactory(),
+                    subscriptionManagerEPR,
+                    new QName(EventingConstants.WSE_EVENTING_NS,
+                            EventingConstants.WSE_EN_SUBSCRIPTION_MANAGER,
+                            EventingConstants.WSE_EVENTING_PREFIX),
+                    AddressingConstants.Submission.WSA_NAMESPACE);
+            subscribeResponseElement.addChild(subscriptionManagerElement);
+            message.getBody().addChild(subscribeResponseElement); 
         } catch (AxisFault axisFault) {
-            handleException("unable to create subscription 
response",axisFault);
+            handleException("unable to create subscription response", 
axisFault);
         }
         return message;
     }
-        private void handleException(String message) {
+
+    private void handleException(String message) {
         log.error(message);
         throw new SynapseException(message);
     }
@@ -81,4 +115,47 @@
         log.error(message, e);
         throw new SynapseException(message, e);
     }
+
+    /**
+     * (01) <s12:Envelope
+     * (02)     xmlns:s12="http://www.w3.org/2003/05/soap-envelope";
+     * (03)     xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"; >
+     * (04)   <s12:Header>
+     * (05)     <wsa:Action>
+     * (06) http://schemas.xmlsoap.org/ws/2004/08/eventing/UnsubscribeResponse
+     * (07)     </wsa:Action>
+     * (08)     <wsa:RelatesTo>
+     * (09)       uuid:2653f89f-25bc-4c2a-a7c4-620504f6b216
+     * (10)     </wsa:RelatesTo>
+     * (11)     <wsa:To>http://www.example.com/MyEventSink</wsa:To>
+     * (12)   </s12:Header>
+     * (13)   <s12:Body />
+     * (14) </s12:Envelope>
+     *
+     * @param subscription
+     * @return
+     */
+    public SOAPEnvelope genUnSubscribeResponse(Subscription subscription) {
+        SOAPEnvelope message = factory.getDefaultEnvelope();
+        EndpointReference subscriptionManagerEPR = new 
EndpointReference("http://localhost:8280/soap/eventing";); //TODO: add 
subscription url to subscription object
+        subscriptionManagerEPR.addReferenceParameter(new 
QName(EventingConstants.WSE_EVENTING_NS,
+                EventingConstants.WSE_EN_IDENTIFIER, 
EventingConstants.WSE_EVENTING_PREFIX), subscription.getId());
+        OMNamespace eventingNamespace = 
factory.createOMNamespace(EventingConstants.WSE_EVENTING_NS,
+                EventingConstants.WSE_EVENTING_PREFIX);
+        OMElement subscribeResponseElement = 
factory.createOMElement(EventingConstants.WSE_EN_UNSUBSCRIBE, 
eventingNamespace);
+        try {
+            OMElement subscriptionManagerElement = 
EndpointReferenceHelper.toOM(
+                    subscribeResponseElement.getOMFactory(),
+                    subscriptionManagerEPR,
+                    new QName(EventingConstants.WSE_EVENTING_NS,
+                            EventingConstants.WSE_EN_SUBSCRIPTION_MANAGER,
+                            EventingConstants.WSE_EVENTING_PREFIX),
+                    AddressingConstants.Submission.WSA_NAMESPACE);
+            subscribeResponseElement.addChild(subscriptionManagerElement);
+            message.getBody().addChild(subscribeResponseElement);
+        } catch (AxisFault axisFault) {
+            handleException("unable to create subscription response", 
axisFault);
+        }
+        return message;
+    }
 }

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to