You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2005/09/21 05:31:36 UTC
svn commit: r290608 - in /webservices/axis2/trunk/java/modules:
addressing/src/org/apache/axis2/handlers/addressing/
core/src/org/apache/axis2/ core/src/org/apache/axis2/addressing/
core/src/org/apache/axis2/context/ core/src/org/apache/axis2/descripti...
Author: chinthaka
Date: Tue Sep 20 20:31:06 2005
New Revision: 290608
URL: http://svn.apache.org/viewcvs?rev=290608&view=rev
Log:
Adding service group context test
making addressing to pick up the sgc id
Added:
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounterMessageReceiver.java
Modified:
webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/InstanceDispatcher.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/OperationContext.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPHeader.java
Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java Tue Sep 20 20:31:06 2005
@@ -17,6 +17,7 @@
package org.apache.axis2.handlers.addressing;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.AnyContentType;
import org.apache.axis2.addressing.EndpointReference;
@@ -78,6 +79,10 @@
}
}
msgContext.setProperty(WS_ADDRESSING_VERSION, addressingNamespace, true);
+
+ // extract service group context, if available
+ extractServiceGroupContextId(header, msgContext);
+
} catch (AddressingException e) {
logger.info("Exception occurred in Addressing Module");
throw new AxisFault(e);
@@ -85,6 +90,14 @@
}
+ private void extractServiceGroupContextId(SOAPHeader header, MessageContext msgContext) {
+ OMElement serviceGroupId = header.getFirstChildWithName(new QName(Constants.AXIS2_NAMESPACE_URI,
+ Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX));
+ if (serviceGroupId != null) {
+ msgContext.setProperty( PARAM_SERVICE_GROUP_CONTEXT_ID, serviceGroupId.getText());
+ }
+ }
+
/**
* WSA 1.0 specification mandates all the reference parameters to have a attribute as wsa:Type=�parameter�. So
* here this will check for header blocks with the above attribute and will put them in message information header collection
@@ -154,6 +167,7 @@
//here the addressing epr overidde what ever already there is
epr = new EndpointReference(soapHeaderBlock.getText());
messageInformationHeaders.setTo(epr);
+ soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_FROM.equals(soapHeaderBlock.getLocalName())) {
epr = messageInformationHeaders.getFrom();
if (epr == null) {
@@ -161,6 +175,7 @@
messageInformationHeaders.setFrom(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
+ soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName())) {
epr = messageInformationHeaders.getReplyTo();
if (epr == null) {
@@ -168,6 +183,7 @@
messageInformationHeaders.setReplyTo(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
+ soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName())) {
epr = messageInformationHeaders.getFaultTo();
if (epr == null) {
@@ -175,10 +191,13 @@
messageInformationHeaders.setFaultTo(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
+ soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
messageInformationHeaders.setMessageId(soapHeaderBlock.getText());
+ soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_ACTION.equals(soapHeaderBlock.getLocalName())) {
messageInformationHeaders.setAction(soapHeaderBlock.getText());
+ soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName())) {
String address = soapHeaderBlock.getText();
OMAttribute relationshipType =
@@ -195,6 +214,8 @@
? relationshipTypeDefaultValue
: relationshipType.getValue());
messageInformationHeaders.setRelatesTo(relatesTo);
+ soapHeaderBlock.setProcessed();
+
}
}
@@ -209,11 +230,11 @@
Iterator childElements = headerBlock.getChildElements();
while (childElements.hasNext()) {
OMElement eprChildElement = (OMElement) childElements.next();
- if (checkElement(new QName(addressingNamespace, AddressingConstants.EPR_ADDRESS), eprChildElement.getQName())){
+ if (checkElement(new QName(addressingNamespace, AddressingConstants.EPR_ADDRESS), eprChildElement.getQName())) {
epr.setAddress(eprChildElement.getText());
- } else if (checkElement(new QName(addressingNamespace, AddressingConstants.EPR_REFERENCE_PARAMETERS), eprChildElement.getQName())){
+ } else if (checkElement(new QName(addressingNamespace, AddressingConstants.EPR_REFERENCE_PARAMETERS), eprChildElement.getQName())) {
AnyContentType anyContentType = new AnyContentType();
- if(epr.getReferenceParameters() == null){
+ if (epr.getReferenceParameters() == null) {
epr.setReferenceParameters(anyContentType);
}
Iterator referenceParameters = eprChildElement.getChildElements();
@@ -221,9 +242,9 @@
OMElement element = (OMElement) referenceParameters.next();
epr.getReferenceParameters().addReferenceValue(element.getQName(), element.getText());
}
- } else if (checkElement(new QName(addressingNamespace, AddressingConstants.Final.WSA_METADATA), eprChildElement.getQName())){
+ } else if (checkElement(new QName(addressingNamespace, AddressingConstants.Final.WSA_METADATA), eprChildElement.getQName())) {
AnyContentType anyContentType = new AnyContentType();
- if(epr.getMetadata() == null){
+ if (epr.getMetadata() == null) {
epr.setMetadata(anyContentType);
}
Iterator metadataChildren = eprChildElement.getChildElements();
Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java Tue Sep 20 20:31:06 2005
@@ -17,11 +17,8 @@
package org.apache.axis2.handlers.addressing;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AnyContentType;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.MessageInformationHeaders;
-import org.apache.axis2.addressing.ServiceName;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.*;
import org.apache.axis2.addressing.miheaders.RelatesTo;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.handlers.AbstractHandler;
@@ -49,8 +46,7 @@
OMNamespace addressingNamespaceObject;
String addressingNamespace;
- private String axis2NamespacePrefix = "axis2";
- private String axis2NamespaceURI = "http://ws.apache.org/namespaces/axis2";
+
public void invoke(MessageContext msgContext) throws AxisFault {
@@ -123,8 +119,8 @@
// add the service group id as a reference parameter
String serviceGroupContextId = msgContext.getServiceGroupContextId();
if (serviceGroupContextId != null && "".equals(serviceGroupContextId)) {
- epr.getReferenceParameters().addReferenceValue(new QName(axis2NamespaceURI,
- "ServiceGroupId", axis2NamespacePrefix), serviceGroupContextId);
+ epr.getReferenceParameters().addReferenceValue(new QName(Constants.AXIS2_NAMESPACE_URI,
+ Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX), serviceGroupContextId);
}
addToSOAPHeader(epr, AddressingConstants.WSA_REPLY_TO, soapHeader);
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java Tue Sep 20 20:31:06 2005
@@ -208,6 +208,10 @@
}
+ public static final String AXIS2_NAMESPACE_PREFIX = "axis2";
+ public static final String AXIS2_NAMESPACE_URI = "http://ws.apache.org/namespaces/axis2";
+
+ public static final String SERVICE_GROUP_ID = "ServiceGroupId";
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/InstanceDispatcher.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/InstanceDispatcher.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/InstanceDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/InstanceDispatcher.java Tue Sep 20 20:31:06 2005
@@ -16,11 +16,7 @@
package org.apache.axis2;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.OperationContextFactory;
-import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.context.*;
import org.apache.axis2.description.OperationDescription;
import org.apache.axis2.handlers.AbstractHandler;
@@ -42,6 +38,7 @@
public void invoke(MessageContext msgContext) throws AxisFault {
if(msgContext.getOperationContext() != null && msgContext.getServiceContext() != null){
+ msgContext.setServiceGroupContextId(((ServiceGroupContext) msgContext.getServiceContext().getParent()).getId());
return;
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java Tue Sep 20 20:31:06 2005
@@ -73,4 +73,6 @@
public static final String WS_ADDRESSING_VERSION = "WSAddressingVersion";
public static final String WSA_DEFAULT_PRFIX = "wsa";
+ public static final String PARAM_SERVICE_GROUP_CONTEXT_ID = "ServiceGroupContextIdFromAddressing";
+
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java Tue Sep 20 20:31:06 2005
@@ -17,9 +17,11 @@
package org.apache.axis2.context;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.description.ServiceGroupDescription;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.storage.AxisStorage;
+import org.apache.axis2.transport.http.AxisServlet;
import org.apache.axis2.util.UUIDGenerator;
import org.apache.axis2.util.threadpool.ThreadPool;
@@ -55,7 +57,7 @@
*/
private final Map operationContextMap = new HashMap();
- private final Map serviceContextMap = new HashMap ();
+ private final Map serviceContextMap = new HashMap();
private final Map serviceGroupContextMap = new HashMap();
@@ -78,42 +80,42 @@
serviceContextMap.remove(name);
}
-
+
public void init(AxisConfiguration axisConfiguration) throws AxisFault {
- this.axisConfiguration = axisConfiguration;
+ this.axisConfiguration = axisConfiguration;
+
+ Iterator operationContextIt = operationContextMap.keySet().iterator();
+ while (operationContextIt.hasNext()) {
+ Object key = operationContextIt.next();
+ OperationContext operationContext = (OperationContext) operationContextMap.get(key);
+ if (operationContext != null)
+ operationContext.init(axisConfiguration);
+ }
+
+ Iterator serviceContextIt = serviceContextMap.keySet().iterator();
+ while (serviceContextIt.hasNext()) {
+ Object key = serviceContextIt.next();
+ ServiceContext serviceContext = (ServiceContext) serviceContextMap.get(key);
+ if (serviceContext != null)
+ serviceContext.init(axisConfiguration);
+ }
- Iterator operationContextIt = operationContextMap.keySet().iterator();
- while (operationContextIt.hasNext()) {
- Object key = operationContextIt.next();
- OperationContext operationContext = (OperationContext) operationContextMap.get(key);
- if (operationContext!=null)
- operationContext.init(axisConfiguration);
- }
-
- Iterator serviceContextIt = serviceContextMap.keySet().iterator();
- while (serviceContextIt.hasNext()) {
- Object key = serviceContextIt.next();
- ServiceContext serviceContext = (ServiceContext) serviceContextMap.get(key);
- if (serviceContext!=null)
- serviceContext.init(axisConfiguration);
- }
-
- Iterator serviceGroupContextIt = serviceGroupContextMap.keySet().iterator();
- while (serviceGroupContextIt.hasNext()) {
- Object key = serviceGroupContextIt.next();
- ServiceGroupContext serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(key);
- if (serviceGroupContext!=null)
- serviceGroupContext.init(axisConfiguration);
- }
+ Iterator serviceGroupContextIt = serviceGroupContextMap.keySet().iterator();
+ while (serviceGroupContextIt.hasNext()) {
+ Object key = serviceGroupContextIt.next();
+ ServiceGroupContext serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(key);
+ if (serviceGroupContext != null)
+ serviceGroupContext.init(axisConfiguration);
+ }
}
private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
+ out.defaultWriteObject();
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- threadPool = new ThreadPool ();
+ in.defaultReadObject();
+ threadPool = new ThreadPool();
}
/**
@@ -182,7 +184,6 @@
}
-
/**
* @return the Gloal ThradPool
*/
@@ -229,8 +230,17 @@
public ServiceGroupContext fillServiceContextAndServiceGroupContext(MessageContext messageContext) throws AxisFault {
String serviceGroupContextId = messageContext.getServiceGroupContextId();
+ if (isNull(serviceGroupContextId)) {
+ // try to get the id from addressing
+ serviceGroupContextId = (String) messageContext.getProperty(AddressingConstants.PARAM_SERVICE_GROUP_CONTEXT_ID);
+ if (serviceContextMap.get(serviceGroupContextId) == null) {
+ // try session id
+ serviceGroupContextId = (String) messageContext.getProperty(AxisServlet.SESSION_ID);
+ }
+ }
+
ServiceGroupContext serviceGroupContext;
- ServiceContext serviceContext ;
+ ServiceContext serviceContext;
if (!isNull(serviceGroupContextId) && serviceGroupContextMap.get(serviceGroupContextId) != null) {
// SGC is already there
serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
@@ -252,16 +262,16 @@
serviceGroupContextId = UUIDGenerator.getUUID();
messageContext.setServiceGroupContextId(serviceGroupContextId);
}
- if(messageContext.getServiceDescription() !=null){
+ if (messageContext.getServiceDescription() != null) {
// String servicName = messageContext.getServiceDescription().getName().getLocalPart();
ServiceGroupDescription servicGroupDescription =
messageContext.getServiceDescription().getParent();
// ServiceGroupDescription servicGroupDescription =
// this.getAxisConfiguration().getServiceGroup(servicName);
- serviceGroupContext = servicGroupDescription.getServiceGroupContext(this);
+ serviceGroupContext = servicGroupDescription.getServiceGroupContext(this);
serviceContext = serviceGroupContext.getServiceContext(
messageContext.getServiceDescription().getName().
- getLocalPart());
+ getLocalPart());
this.registerServiceGroupContext(serviceGroupContext);
} else {
throw new AxisFault("ServiceDescription Not found yet");
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/OperationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/OperationContext.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/OperationContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/OperationContext.java Tue Sep 20 20:31:06 2005
@@ -233,10 +233,10 @@
* being complete due to the optional nature of the MEP.
*/
public void cleanup() {
- if (null != this.inMessageContext) {
+ if (null != this.inMessageContext && operationContextMap != null) {
operationContextMap.remove(inMessageContext.getMessageID());
}
- if (null != this.outMessageContext) {
+ if (null != this.outMessageContext && operationContextMap != null) {
operationContextMap.remove(outMessageContext.getMessageID());
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java Tue Sep 20 20:31:06 2005
@@ -24,13 +24,7 @@
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.phaseresolver.PhaseResolver;
-import org.apache.wsdl.WSDLBindingOperation;
-import org.apache.wsdl.WSDLEndpoint;
-import org.apache.wsdl.WSDLExtensibilityAttribute;
-import org.apache.wsdl.WSDLExtensibilityElement;
-import org.apache.wsdl.WSDLInterface;
-import org.apache.wsdl.WSDLOperation;
-import org.apache.wsdl.WSDLService;
+import org.apache.wsdl.*;
import org.apache.wsdl.extensions.ExtensionConstants;
import org.apache.wsdl.extensions.SOAPOperation;
import org.apache.wsdl.impl.WSDLInterfaceImpl;
@@ -45,13 +39,7 @@
import javax.xml.namespace.QName;
import java.io.IOException;
import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* Class ServiceDescription
@@ -598,7 +586,7 @@
* @param msgContext
* @return ServiceContext
*/
- public ServiceContext findServiceContext(MessageContext msgContext) {
+ public ServiceContext u(MessageContext msgContext) {
// TODO : Fix me. Can't look up a service context in the system context
ServiceContext serviceContext = null;
@@ -620,7 +608,7 @@
/**
* To get the description about the service
- *
+ * ty67tyuio
* @return String
*/
public String getServiceDescription() {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java Tue Sep 20 20:31:06 2005
@@ -17,10 +17,7 @@
package org.apache.axis2.engine;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.*;
import org.apache.axis2.description.HandlerDescription;
import org.apache.axis2.description.OperationDescription;
import org.apache.axis2.description.ServiceDescription;
@@ -74,6 +71,7 @@
msgctx.setServiceContext((ServiceContext) operationContext.getParent());
msgctx.setServiceDescription(((ServiceContext) operationContext.getParent()).getServiceConfig());
msgctx.getOperationDescription().registerOperationContext(msgctx, operationContext);
+ msgctx.setServiceGroupContextId(((ServiceGroupContext) msgctx.getServiceContext().getParent()).getId());
}
}
return;
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java Tue Sep 20 20:31:06 2005
@@ -45,6 +45,7 @@
private ListingAgent lister;
private static final String CONFIGURATION_CONTEXT = "CONFIGURATION_CONTEXT";
private ConfigurationContext configContext;
+ public static final String SESSION_ID = "SessionId";
/**
* Method init
@@ -113,7 +114,7 @@
msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, getTransportHeaders(httpServletRequest));
out = httpServletResponse.getOutputStream();
- msgContext.setServiceGroupContextId(httpServletRequest.getSession().getId());
+ msgContext.setProperty(SESSION_ID, httpServletRequest.getSession().getId());
boolean processed =
HTTPTransportUtils.processHTTPGetRequest(msgContext,
httpServletRequest.getInputStream(),
@@ -175,6 +176,7 @@
msgContext.setProperty(HTTPConstants.HTTPOutTransportInfo,
new ServletBasedOutTransportInfo(res));
msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, getTransportHeaders(req));
+ msgContext.setProperty(SESSION_ID, req.getSession().getId());
out = res.getOutputStream();
HTTPTransportUtils.processHTTPPostRequest(msgContext,
Added: 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=290608&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java Tue Sep 20 20:31:06 2005
@@ -0,0 +1,100 @@
+package org.apache.axis2.engine;
+
+import junit.framework.TestCase;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.engine.util.RequestCounter;
+import org.apache.axis2.engine.util.RequestCounterMessageReceiver;
+import org.apache.axis2.integration.TestingUtils;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.SOAPHeaderBlock;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+public class ServiceGroupContextTest extends TestCase {
+ protected EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:" +
+ (5556) +
+// (UtilServer.TESTING_PORT) +
+ "/axis/services/RequestCounter");
+ protected Log log = LogFactory.getLog(getClass());
+ protected QName serviceName = new QName("RequestCounter");
+ protected QName operationName = new QName("getRequestCount");
+ protected QName transportName = new QName("http://localhost/my", "NullTransport");
+ protected ServiceDescription service;
+
+ protected void setUp() throws Exception {
+ UtilServer.start();
+ service = Utils.createSimpleService(serviceName, new RequestCounterMessageReceiver(),
+ RequestCounter.class.getName(), operationName);
+ UtilServer.deployService(service);
+ }
+
+ protected void tearDown() throws Exception {
+ UtilServer.unDeployService(serviceName);
+ UtilServer.stop();
+ UtilServer.unDeployClientService();
+ }
+
+ public void testEchoXMLSync() throws Exception {
+ SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+ OMElement payload = TestingUtils.createDummyOMElement();
+
+ org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call("target/test-resources/intregrationRepo");
+
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+ call.setWsaAction(operationName.getLocalPart());
+
+ OMElement result = call.invokeBlocking(operationName.getLocalPart(), payload);
+
+// print(result);
+
+ OMNamespace axis2Namespace = fac.createOMNamespace(Constants.AXIS2_NAMESPACE_URI,
+ Constants.AXIS2_NAMESPACE_PREFIX);
+ SOAPEnvelope defaultEnvelope = fac.getDefaultEnvelope();
+ SOAPHeaderBlock soapHeaderBlock = defaultEnvelope.getHeader().addHeaderBlock(Constants.SERVICE_GROUP_ID,
+ axis2Namespace);
+ soapHeaderBlock.setText(result.getText());
+
+ SOAPEnvelope soapEnvelope = call.invokeBlocking(operationName.getLocalPart(),
+ defaultEnvelope);
+// print(soapEnvelope.getBody().getFirstElement());
+ }
+
+// private void print(OMElement result) throws XMLStreamException {
+// System.out.println("*******************************************");
+// OMOutputImpl out = new OMOutputImpl(System.out, false);
+// result.serializeWithCache(out);
+// out.flush();
+// System.out.println("*******************************************");
+//
+// }
+}
Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java?rev=290608&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java Tue Sep 20 20:31:06 2005
@@ -0,0 +1,38 @@
+package org.apache.axis2.engine.util;
+
+import org.apache.axis2.context.MessageContext;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class RequestCounter {
+
+ public static final String REQUEST_COUNT = "Request_Count";
+
+ public void getRequestCount(MessageContext inMessageContext, MessageContext outMessageContext) {
+ Integer requestCount = (Integer) inMessageContext.getServiceGroupContext().getProperty(REQUEST_COUNT);
+ if (requestCount == null) {
+ requestCount = new Integer(1);
+ } else {
+ requestCount = new Integer(requestCount.intValue() + 1);
+ }
+
+ inMessageContext.getServiceGroupContext().setProperty(REQUEST_COUNT, requestCount);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounterMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounterMessageReceiver.java?rev=290608&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounterMessageReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounterMessageReceiver.java Tue Sep 20 20:31:06 2005
@@ -0,0 +1,56 @@
+package org.apache.axis2.engine.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class RequestCounterMessageReceiver extends AbstractInOutSyncMessageReceiver {
+
+ public RequestCounterMessageReceiver() {
+ }
+
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+ RequestCounter requestCounter = new RequestCounter();
+ requestCounter.getRequestCount(inMessage, outMessage);
+
+ SOAPFactory factory;
+
+ if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(inMessage.getEnvelope().getNamespace().getName())) {
+ factory = OMAbstractFactory.getSOAP12Factory();
+ } else {
+ factory = OMAbstractFactory.getSOAP11Factory();
+ }
+
+ SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
+ outMessage.setEnvelope(defaultEnvelope);
+
+ OMNamespace axis2Namespace = factory.createOMNamespace("http://ws.apache.org/axis2/namespaces/", "axis2");
+ OMElement firstElement = factory.createOMElement("RequestCount", axis2Namespace, defaultEnvelope.getBody());
+ firstElement.setText(""+((Integer)inMessage.getServiceGroupContext().getProperty(RequestCounter.REQUEST_COUNT)).intValue());
+
+ }
+}
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPHeader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPHeader.java?rev=290608&r1=290607&r2=290608&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPHeader.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPHeader.java Tue Sep 20 20:31:06 2005
@@ -30,7 +30,7 @@
/**
* Creates a new <CODE>SOAPHeaderBlock</CODE> object initialized with the
* specified name and adds it to this <CODE>SOAPHeader</CODE> object.
- *
+ *
* @param localName
* @param ns
* @return the new <CODE>SOAPHeaderBlock</CODE> object that was inserted
@@ -50,7 +50,7 @@
* recipient for the message, so if no role attribute is included in a
* <CODE>SOAPHeader</CODE> object, the message is sent to its ultimate
* destination.
- *
+ *
* @param role
* a <CODE>String</CODE> giving the URI of the role for which
* to search
@@ -69,7 +69,7 @@
* This method allows an role to process only the parts of the <CODE>
* SOAPHeader</CODE> object that apply to it and to remove them before
* passing the message on to the next role.
- *
+ *
* @param role
* a <CODE>String</CODE> giving the URI of the role for which
* to search
@@ -85,7 +85,7 @@
* <code>SOAPHeaderBlock</code> objects in this <code>SOAPHeader</code>
* object that have the specified role and that have a MustUnderstand
* attribute whose value is equivalent to <code>true</code>.
- *
+ *
* @param role
* a <code>String</code> giving the URI of the role for which
* to search
@@ -99,7 +99,7 @@
* Returns an <code>Iterator</code> over all the
* <code>SOAPHeaderBlock</code> objects in this <code>SOAPHeader</code>
* object.
- *
+ *
* @return an <code>Iterator</code> object over all the
* <code>SOAPHeaderBlock</code> objects contained by this
* <code>SOAPHeader</code>. If there are no header blocks then an
@@ -111,7 +111,7 @@
* Returns an <code>Iterator</code> over all the
* <code>SOAPHeaderBlock</code> objects in this <code>SOAPHeader </code>
* object and detaches them from this <code>SOAPHeader</code> object.
- *
+ *
* @return an <code>Iterator</code> object over all the
* <code>SOAPHeaderBlock</code> objects contained by this
* <code>SOAPHeader</code>
@@ -120,7 +120,7 @@
/**
* Return all the Headers that has the Namespace URI to given NS URI
- *
+ *
* @param nsURI
* @return
*/