ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r370455 - in /webservices/axis2/trunk/java/modules: core/src/org/apache/axis2/client/ core/src/org/apache/axis2/context/ core/src/org/apache/axis2/description/ integration/test/org/apache/axis2/engine/
Date Thu, 19 Jan 2006 10:02:21 GMT
Author: deepal
Date: Thu Jan 19 02:01:58 2006
New Revision: 370455

URL: http://svn.apache.org/viewcvs?rev=370455&view=rev
Log:
- burn Session management stuff into operation client and which can control using options.
- when manage session set to true in option operation client will store wsa:reploTo reference
parameters into ServiceConetext and when sending next request add them as SOAP header parameters.


Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java?rev=370455&r1=370454&r2=370455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java Thu
Jan 19 02:01:58 2006
@@ -94,6 +94,10 @@
 
     private EndpointReference to;
 
+    //To control , session managment , default is set to true , if user wants he can set
that to true
+    // There operation clinet will manage session using ServiceGroupID if it is there in
the response
+    private boolean manageSession = false;
+
     /**
      * Default constructor
      */
@@ -483,5 +487,13 @@
         }
 
         referenceParameters.add(referenceParameter);
+    }
+
+    public boolean isManageSession() {
+        return manageSession;
+    }
+
+    public void setManageSession(boolean manageSession) {
+        this.manageSession = manageSession;
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java?rev=370455&r1=370454&r2=370455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
Thu Jan 19 02:01:58 2006
@@ -21,6 +21,7 @@
 import org.apache.axis2.description.AxisService;
 
 import javax.xml.namespace.QName;
+import java.util.ArrayList;
 
 /**
  * Well this is never clearly defined, what it does or the lifecycle.
@@ -34,12 +35,13 @@
 
     //to store service implementation class , to handler session
     private Object serviceImpl;
+    private ArrayList replyTorefpars;
 
     public ServiceContext(AxisService serviceConfig, ServiceGroupContext serviceGroupContext)
{
         super(serviceGroupContext);
         this.serviceGroupContext = serviceGroupContext;
         this.axisService = serviceConfig;
-
+        this.replyTorefpars = new ArrayList();
         if (serviceConfig != null) {
             serviceInstanceID = serviceConfig.getName();
         }
@@ -87,5 +89,13 @@
 
     public ServiceGroupContext getServiceGroupContext() {
         return serviceGroupContext;
+    }
+
+    public ArrayList getReplyTorefpars() {
+        return replyTorefpars;
+    }
+
+    public void setReplyTorefpars(ArrayList replyTorefpars) {
+        this.replyTorefpars = replyTorefpars;
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java?rev=370455&r1=370454&r2=370455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
Thu Jan 19 02:01:58 2006
@@ -13,16 +13,21 @@
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMException;
 import org.apache.axis2.soap.SOAPBody;
 import org.apache.axis2.soap.SOAPEnvelope;
 import org.apache.axis2.soap.SOAPFault;
+import org.apache.axis2.soap.SOAPHeader;
 import org.apache.axis2.transport.TransportUtils;
 import org.apache.axis2.util.CallbackReceiver;
 import org.apache.axis2.util.UUIDGenerator;
 import org.apache.wsdl.WSDLConstants;
 
 import javax.xml.namespace.QName;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 
 /**
  * Author: Deepal Jayasinghe Date: Oct 3, 2005 Time: 6:01:33 PM
@@ -243,7 +248,7 @@
                 mc.setSoapAction((String) soapaction.getValue());
             }
         }
-
+        addRefParsToRequset(mc.getEnvelope());
         if (options.isUseSeparateListener()) {
             CallbackReceiver callbackReceiver = (CallbackReceiver) axisOp
                     .getMessageReceiver();
@@ -304,6 +309,19 @@
         }
     }
 
+    private void addRefParsToRequset(SOAPEnvelope env) {
+        if (options.isManageSession()) {
+            SOAPHeader sh = env.getHeader();
+            ArrayList replyTorefpars = sc.getReplyTorefpars();
+            if (replyTorefpars.size() > 0) {
+                for (int i = 0; i < replyTorefpars.size(); i++) {
+                    OMElement refPars = (OMElement) replyTorefpars.get(i);
+                    sh.addChild(refPars);
+                }
+            }
+        }
+    }
+
     /**
      * Sends the message using a two way transport and waits for a response
      *
@@ -339,6 +357,23 @@
         SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(
                 responseMessageContext, msgctx.getEnvelope().getNamespace()
                 .getName());
+        try {
+            // Adding request reference parameters into ServiceContext , so then in the next
+            // requesy automatically send them back
+            OMElement refernceParameters = resenvelope.getHeader()
+                    .getFirstChildWithName(new QName("ReplyTo"))
+                    .getFirstChildWithName(new QName("ReferenceParameters"));
+            ArrayList replyTorefPars = new ArrayList();
+            Iterator refPars = refernceParameters.getChildren();
+            while (refPars.hasNext()) {
+                OMElement omElement = (OMElement) refPars.next();
+                replyTorefPars.add(omElement);
+            }
+            sc.setReplyTorefpars(replyTorefPars);
+
+        } catch (Exception e) {
+            //NPE may occure there for need to catch this
+        }
 
         if (resenvelope != null) {
             responseMessageContext.setEnvelope(resenvelope);

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java?rev=370455&r1=370454&r2=370455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
Thu Jan 19 02:01:58 2006
@@ -85,6 +85,7 @@
         SOAPEnvelope payload = fac.getDefaultEnvelope();
         Options options = new Options();
         options.setTo(targetEPR);
+        options.setManageSession(true);
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         options.setAction(operationName.getLocalPart());
@@ -104,14 +105,14 @@
         OMElement body = (OMElement) result.getParent();
         SOAPEnvelope soapEnvlop = (SOAPEnvelope) body.getParent();
 
-        String serviceGroupId = soapEnvlop.getHeader().getFirstChildWithName(new QName("ReplyTo"))
+        String serviceGroupIds= soapEnvlop.getHeader().getFirstChildWithName(new QName("ReplyTo"))
                 .getFirstChildWithName(new QName("ReferenceParameters")).
                 getFirstChildWithName(new QName("ServiceGroupId")).getText();
 
-        OMElement soapHeaderElement = fac.createOMElement(Constants.SERVICE_GROUP_ID, axis2Namespace);
-        soapHeaderElement.setText(serviceGroupId);
+//        OMElement soapHeaderElement = fac.createOMElement(Constants.SERVICE_GROUP_ID, axis2Namespace);
+//        soapHeaderElement.setText(serviceGroupId);
 
-        sender.addHeader(soapHeaderElement);
+//        sender.addHeader(soapHeaderElement);
         OMElement result2 = sender.sendReceive(defaultEnvelope.getBody().getFirstElement());
         String text = result2.getText();
         assertEquals("Number of requests should be 2", 2, Integer.parseInt(text));



Mime
View raw message