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 2006/02/07 11:28:03 UTC
svn commit: r375565 - in /webservices/axis2/trunk/java/modules:
addressing/src/META-INF/ addressing/src/org/apache/axis2/handlers/addressing/
addressing/test-resources/
addressing/test/org/apache/axis2/handlers/addressing/
core/src/org/apache/axis2/add...
Author: chinthaka
Date: Tue Feb 7 02:28:00 2006
New Revision: 375565
URL: http://svn.apache.org/viewcvs?rev=375565&view=rev
Log:
Cleaning up AddressingInHandlers. Need to clean up AddressingOutHandlers.
Modified:
webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml
webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingHandler.java
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/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
webservices/axis2/trunk/java/modules/addressing/test-resources/OutHandlerTest.xml
webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml
webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml
webservices/axis2/trunk/java/modules/addressing/test-resources/soapmessage.xml
webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTest.java
webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java
webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java
Modified: webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml Tue Feb 7 02:28:00 2006
@@ -1,12 +1,18 @@
<module name="addressing">
<inflow>
- <handler name="AddressingInHandler" class="org.apache.axis2.handlers.addressing.AddressingInHandler">
+ <handler name="AddressingFinalInHandler" class="org.apache.axis2.handlers.addressing.AddressingFinalInHandler">
+ <order phase="PreDispatch"/>
+ </handler>
+ <handler name="AddressingSubmissionInHandler" class="org.apache.axis2.handlers.addressing.AddressingSubmissionInHandler">
<order phase="PreDispatch"/>
</handler>
</inflow>
<outflow>
- <handler name="AddressingOutHandler" class="org.apache.axis2.handlers.addressing.AddressingOutHandler">
+ <handler name="AddressingFinalOutHandler" class="org.apache.axis2.handlers.addressing.AddressingFinalOutHandler">
+ <order phase="MessageOut"/>
+ </handler>
+ <handler name="AddressingOutHandler" class="org.apache.axis2.handlers.addressing.AddressingSubmissionOutHandler">
<order phase="MessageOut"/>
</handler>
</outflow>
Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java Tue Feb 7 02:28:00 2006
@@ -1,5 +1,15 @@
package org.apache.axis2.handlers.addressing;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.ws.commons.om.OMAttribute;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.soap.SOAPHeader;
+import org.apache.ws.commons.soap.SOAPHeaderBlock;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -19,6 +29,48 @@
public class AddressingFinalInHandler extends AddressingInHandler {
- private static final long serialVersionUID = -4020680449342946484L;
+ private static final long serialVersionUID = -4020680449342946484L;
+
+ public AddressingFinalInHandler() {
+ addressingNamespace = Final.WSA_NAMESPACE;
+ addressingVersion = "WS-Addressing Final";
+ }
+
+
+ protected void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader header) {
+ Iterator headerBlocks = header.getChildElements();
+ while (headerBlocks.hasNext()) {
+ SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) headerBlocks.next();
+ OMAttribute isRefParamAttr = soapHeaderBlock.getAttribute(new QName(addressingNamespace, "IsReferenceParameter"));
+ if (isRefParamAttr != null && "true".equals(isRefParamAttr.getAttributeValue())) {
+ toEPR.addReferenceParameter(soapHeaderBlock.getQName(), soapHeaderBlock.getText());
+ }
+ }
+ }
+
+ protected void extractEPRInformation(SOAPHeaderBlock headerBlock, EndpointReference epr, String addressingNamespace) {
+
+ Iterator childElements = headerBlock.getChildElements();
+ while (childElements.hasNext()) {
+ OMElement eprChildElement = (OMElement) childElements.next();
+ 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())) {
+
+ Iterator referenceParameters = eprChildElement.getChildElements();
+ while (referenceParameters.hasNext()) {
+ OMElement element = (OMElement) referenceParameters.next();
+ epr.addReferenceParameter(element);
+ }
+ } else
+ if (checkElement(new QName(addressingNamespace, AddressingConstants.Final.WSA_METADATA), eprChildElement.getQName()))
+ {
+ epr.setMetaData(eprChildElement);
+ }
+ }
+ }
}
Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingHandler.java?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingHandler.java Tue Feb 7 02:28:00 2006
@@ -28,6 +28,7 @@
protected boolean isAddressingOptional = true;
protected String addressingNamespace = null;
+ protected String addressingVersion = null;
protected Log logger = LogFactory.getLog(getClass());
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=375565&r1=375564&r2=375565&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 Feb 7 02:28:00 2006
@@ -33,46 +33,32 @@
import java.util.ArrayList;
import java.util.Iterator;
-public class AddressingInHandler extends AddressingHandler {
+public abstract class AddressingInHandler extends AddressingHandler {
private static final long serialVersionUID = 3907988439637261572L;
- public void invoke(MessageContext msgContext) throws AxisFault {
- logger.debug("Starting Addressing IN Handler .........");
+ public void invoke(MessageContext msgContext) throws AxisFault {
SOAPHeader header = msgContext.getEnvelope().getHeader();
- if (header == null) {
+
+ // if there are no headers or addressing version is already determined, pass through
+ if (header == null || msgContext.getProperty(WS_ADDRESSING_VERSION) != null) {
return;
}
+ logger.debug("Starting " + addressingVersion + " IN handler ...");
+
ArrayList addressingHeaders;
try {
- addressingHeaders = header.getHeaderBlocksWithNSURI(Submission.WSA_NAMESPACE);
+ addressingHeaders = header.getHeaderBlocksWithNSURI(addressingNamespace);
if (addressingHeaders != null && addressingHeaders.size() > 0) {
- addressingNamespace = Submission.WSA_NAMESPACE;
- extractCommonAddressingParameters(
- header,
- msgContext.getOptions(),
- addressingHeaders, Submission.WSA_NAMESPACE);
+ msgContext.setProperty(WS_ADDRESSING_VERSION, addressingNamespace);
+
+ logger.debug(addressingVersion + " Headers present in the SOAP message. Starting to process ...");
+ extractAddressingInformation(header, msgContext.getOptions(),
+ addressingHeaders, addressingNamespace);
} else {
- addressingHeaders = header.getHeaderBlocksWithNSURI(Final.WSA_NAMESPACE);
- if (addressingHeaders != null && addressingHeaders.size() > 0) {
- addressingNamespace = Final.WSA_NAMESPACE;
- extractCommonAddressingParameters(
- header,
- msgContext.getOptions(),
- addressingHeaders, Final.WSA_NAMESPACE);
- extractReferenceParameters(header, msgContext.getOptions());
-
- } else {
- // Addressing headers are not present in the SOAP message
- if (!isAddressingOptional) {
- throw new AxisFault("Addressing Handlers should present, but doesn't present in the incoming message !!");
- }
- logger.debug(
- "No Addressing Headers present in the IN message. Addressing In Handler does nothing.");
- }
+ logger.debug("No Headers present corresponding to " + addressingVersion);
}
- msgContext.setProperty(WS_ADDRESSING_VERSION, addressingNamespace);
// extract service group context, if available
extractServiceGroupContextId(header, msgContext);
@@ -84,45 +70,8 @@
}
- private void extractServiceGroupContextId(SOAPHeader header, MessageContext msgContext) throws AxisFault {
- OMElement serviceGroupId = header.getFirstChildWithName(new QName(Constants.AXIS2_NAMESPACE_URI,
- Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX));
- if (serviceGroupId != null) {
- String groupId = serviceGroupId.getText();
- ServiceGroupContext serviceGroupContext = msgContext.getConfigurationContext().
- getServiceGroupContext(groupId,msgContext);
- if (serviceGroupContext == null) {
- throw new AxisFault("Invalid Service Group Id." + groupId);
- }
- msgContext.setServiceGroupContextId(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
- *
- * @param header
- * @param messageContextOptions
- */
- private void extractReferenceParameters(
- SOAPHeader header,
- Options messageContextOptions) {
- Iterator headerBlocks = header.getChildren();
- while (headerBlocks.hasNext()) {
- SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) headerBlocks.next();
- OMAttribute attribute = soapHeaderBlock.getAttribute(new QName(Final.WSA_NAMESPACE, Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE));
- if (attribute != null && Final.WSA_TYPE_ATTRIBUTE_VALUE.equals(attribute.getAttributeValue())) {
- messageContextOptions.addReferenceParameter(soapHeaderBlock);
- }
- }
- }
-
- protected Options extractCommonAddressingParameters(
- SOAPHeader header,
- Options messageContextOptions,
- ArrayList addressingHeaders,
- String addressingNamespace)
+ protected Options extractAddressingInformation(SOAPHeader header, Options messageContextOptions,
+ ArrayList addressingHeaders, String addressingNamespace)
throws AddressingException {
Iterator addressingHeadersIt = addressingHeaders.iterator();
@@ -130,39 +79,13 @@
SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) addressingHeadersIt.next();
EndpointReference epr;
if (AddressingConstants.WSA_TO.equals(soapHeaderBlock.getLocalName())) {
- //here the addressing epr overidde what ever already there in the message context
- epr = new EndpointReference(soapHeaderBlock.getText());
- messageContextOptions.setTo(epr);
-
- // check for reference parameters
- extractToEprReferenceParameters(epr, header);
- soapHeaderBlock.setProcessed();
-
+ extractToEPRInformation(soapHeaderBlock, messageContextOptions, header);
} else if (AddressingConstants.WSA_FROM.equals(soapHeaderBlock.getLocalName())) {
- epr = messageContextOptions.getFrom();
- if (epr == null) {
- epr = new EndpointReference(""); // I don't know the address now. Let me pass the empty string now and fill this
- // once I process the Elements under this.
- messageContextOptions.setFrom(epr);
- }
- extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
- soapHeaderBlock.setProcessed();
+ extractFromEPRInformation(messageContextOptions, soapHeaderBlock, addressingNamespace);
} else if (AddressingConstants.WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName())) {
- epr = messageContextOptions.getReplyTo();
- if (epr == null) {
- epr = new EndpointReference("");
- messageContextOptions.setReplyTo(epr);
- }
- extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
- soapHeaderBlock.setProcessed();
+ extractReplyToEPRInformation(messageContextOptions, soapHeaderBlock, addressingNamespace);
} else if (AddressingConstants.WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName())) {
- epr = messageContextOptions.getFaultTo();
- if (epr == null) {
- epr = new EndpointReference("");
- messageContextOptions.setFaultTo(epr);
- }
- extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
- soapHeaderBlock.setProcessed();
+ extractFaultToEPRInformation(messageContextOptions, soapHeaderBlock, addressingNamespace);
} else if (AddressingConstants.WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
messageContextOptions.setMessageId(soapHeaderBlock.getText());
soapHeaderBlock.setProcessed();
@@ -170,63 +93,107 @@
messageContextOptions.setAction(soapHeaderBlock.getText());
soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName())) {
- String address = soapHeaderBlock.getText();
- OMAttribute relationshipType =
- soapHeaderBlock.getAttribute(
- new QName(AddressingConstants.WSA_RELATES_TO_RELATIONSHIP_TYPE));
- String relationshipTypeDefaultValue =
- Submission.WSA_NAMESPACE.equals(addressingNamespace)
- ? Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE
- : Final.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE;
- RelatesTo relatesTo =
- new RelatesTo(
- address,
- relationshipType == null
- ? relationshipTypeDefaultValue
- : relationshipType.getAttributeValue());
- messageContextOptions.setRelatesTo(relatesTo);
- soapHeaderBlock.setProcessed();
-
+ extractRelatesToInformation(soapHeaderBlock, addressingNamespace, messageContextOptions);
}
}
return messageContextOptions;
}
- private void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader header) {
- Iterator headerBlocks = header.getChildElements();
- while (headerBlocks.hasNext()) {
- SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) headerBlocks.next();
- OMAttribute isRefParamAttr = soapHeaderBlock.getAttribute(new QName(addressingNamespace, "IsReferenceParameter"));
- if (isRefParamAttr != null && "true".equals(isRefParamAttr.getAttributeValue())) {
- toEPR.addReferenceParameter(soapHeaderBlock.getQName(), soapHeaderBlock.getText());
+ protected abstract void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader header);
+
+ private void extractServiceGroupContextId(SOAPHeader header, MessageContext msgContext) throws AxisFault {
+ OMElement serviceGroupId = header.getFirstChildWithName(new QName(Constants.AXIS2_NAMESPACE_URI,
+ Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX));
+ if (serviceGroupId != null) {
+ String groupId = serviceGroupId.getText();
+ ServiceGroupContext serviceGroupContext = msgContext.getConfigurationContext().
+ getServiceGroupContext(groupId, msgContext);
+ if (serviceGroupContext == null) {
+ throw new AxisFault("Invalid Service Group Id." + groupId);
}
+ msgContext.setServiceGroupContextId(serviceGroupId.getText());
}
}
- private void extractEPRInformation(
- SOAPHeaderBlock headerBlock,
- EndpointReference epr,
- String addressingNamespace) {
-
- Iterator childElements = headerBlock.getChildElements();
- while (childElements.hasNext()) {
- OMElement eprChildElement = (OMElement) childElements.next();
- 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())) {
-
- Iterator referenceParameters = eprChildElement.getChildElements();
- while (referenceParameters.hasNext()) {
- OMElement element = (OMElement) referenceParameters.next();
- epr.addReferenceParameter(element);
- }
- } else if (checkElement(new QName(addressingNamespace, AddressingConstants.Final.WSA_METADATA), eprChildElement.getQName())) {
- epr.setMetaData(eprChildElement);
- }
- }
+
+ private void extractRelatesToInformation(SOAPHeaderBlock soapHeaderBlock, String addressingNamespace, Options messageContextOptions) {
+ String address = soapHeaderBlock.getText();
+ OMAttribute relationshipType =
+ soapHeaderBlock.getAttribute(
+ new QName(AddressingConstants.WSA_RELATES_TO_RELATIONSHIP_TYPE));
+ String relationshipTypeDefaultValue =
+ Submission.WSA_NAMESPACE.equals(addressingNamespace)
+ ? Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE
+ : Final.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE;
+ RelatesTo relatesTo =
+ new RelatesTo(
+ address,
+ relationshipType == null
+ ? relationshipTypeDefaultValue
+ : relationshipType.getAttributeValue());
+ messageContextOptions.setRelatesTo(relatesTo);
+ soapHeaderBlock.setProcessed();
+ }
+
+ private void extractFaultToEPRInformation(Options messageContextOptions, SOAPHeaderBlock soapHeaderBlock, String addressingNamespace) {
+ EndpointReference epr;
+ epr = messageContextOptions.getFaultTo();
+ if (epr == null) {
+ epr = new EndpointReference("");
+ messageContextOptions.setFaultTo(epr);
+ }
+ extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
+ soapHeaderBlock.setProcessed();
+ }
+
+ private void extractReplyToEPRInformation(Options messageContextOptions, SOAPHeaderBlock soapHeaderBlock, String addressingNamespace) {
+ EndpointReference epr;
+ epr = messageContextOptions.getReplyTo();
+ if (epr == null) {
+ epr = new EndpointReference("");
+ messageContextOptions.setReplyTo(epr);
+ }
+ extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
+ soapHeaderBlock.setProcessed();
+ }
+
+ private void extractFromEPRInformation(Options messageContextOptions, SOAPHeaderBlock soapHeaderBlock, String addressingNamespace) {
+ EndpointReference epr;
+ epr = messageContextOptions.getFrom();
+ if (epr == null) {
+ epr = new EndpointReference(""); // I don't know the address now. Let me pass the empty string now and fill this
+ // once I process the Elements under this.
+ messageContextOptions.setFrom(epr);
+ }
+ extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
+ soapHeaderBlock.setProcessed();
+ }
+
+ private void extractToEPRInformation(SOAPHeaderBlock soapHeaderBlock, Options messageContextOptions, SOAPHeader header) {
+ EndpointReference epr;
+ //here the addressing epr overidde what ever already there in the message context
+ epr = new EndpointReference(soapHeaderBlock.getText());
+ messageContextOptions.setTo(epr);
+
+ // check for reference parameters
+ extractToEprReferenceParameters(epr, header);
+ soapHeaderBlock.setProcessed();
}
- private boolean checkElement(QName expectedQName, QName actualQName) {
+ /**
+ * Given the soap header block, this should extract the information within EPR.
+ *
+ * @param headerBlock
+ * @param epr
+ * @param addressingNamespace
+ */
+ protected abstract void extractEPRInformation(SOAPHeaderBlock headerBlock, EndpointReference epr, String addressingNamespace);
+
+ /**
+ * @param expectedQName
+ * @param actualQName
+ */
+ protected boolean checkElement(QName expectedQName, QName actualQName) {
return (expectedQName.getLocalPart().equals(actualQName.getLocalPart()) && expectedQName.getNamespaceURI().equals(actualQName.getNamespaceURI()));
}
}
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=375565&r1=375564&r2=375565&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 Feb 7 02:28:00 2006
@@ -23,21 +23,21 @@
import org.apache.axis2.addressing.RelatesTo;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.om.OMAbstractFactory;
import org.apache.ws.commons.om.OMElement;
import org.apache.ws.commons.om.OMNamespace;
import org.apache.ws.commons.soap.SOAPEnvelope;
import org.apache.ws.commons.soap.SOAPHeader;
import org.apache.ws.commons.soap.SOAPHeaderBlock;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.wsdl.WSDLConstants;
import javax.xml.namespace.QName;
import java.util.Iterator;
import java.util.Map;
-public class AddressingOutHandler extends AddressingHandler {
+public abstract class AddressingOutHandler extends AddressingHandler {
private static final long serialVersionUID = -2623986992336863995L;
@@ -107,9 +107,7 @@
}
processReferenceInformation(epr.getAllReferenceParameters(), soapHeader, addressingNamespaceObject);
- processReferenceInformation(epr.getAllReferenceProperties(), soapHeader, addressingNamespaceObject);
- addToHeader(epr, soapHeader, addressingNamespaceObject, addressingNamespace);
}
// processing WSA Action
@@ -220,9 +218,6 @@
addressElement.setText(address);
}
- addToHeader(epr, soapHeaderBlock, addressingNamespaceObject, addressingNamespace);
-
-
Map referenceParameters = epr.getAllReferenceParameters();
if (referenceParameters != null) {
OMElement reference =
@@ -234,41 +229,7 @@
}
- if (Submission.WSA_NAMESPACE.equals(addressingNamespace)) {
- Map referenceProperties = epr.getAllReferenceProperties();
- if (referenceProperties != null) {
- OMElement reference =
- OMAbstractFactory.getOMFactory().createOMElement(
- Submission.EPR_REFERENCE_PROPERTIES,
- addressingNamespaceObject);
- envelope.getHeader().addChild(reference);
- processReferenceInformation(referenceParameters, reference, addressingNamespaceObject);
- }
-
- }
-
}
-
- private void addToHeader(EndpointReference epr, OMElement parentElement, OMNamespace addressingNamespaceObject, String addressingNamespace) {
-
- if (addressingNamespace.equals(Submission.WSA_NAMESPACE)) {
- QName portType = epr.getPortType();
- if (portType != null) {
- OMElement interfaceName =
- OMAbstractFactory.getOMFactory().createOMElement(Submission.EPR_PORT_TYPE, addressingNamespaceObject);
- interfaceName.addChild(
- OMAbstractFactory.getOMFactory().createText(
- portType.getPrefix() + ":" +
- portType.getLocalPart()));
- parentElement.addChild(interfaceName);
- }
-
- // Note : We are not handling ServiceName purposely here. Most of the time, it will not
- // and even from the final version this has been removed.
- }
-
- }
-
/**
* This will add reference parameters and/or reference properties in to the message
Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java Tue Feb 7 02:28:00 2006
@@ -1,5 +1,14 @@
package org.apache.axis2.handlers.addressing;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.soap.SOAPHeader;
+import org.apache.ws.commons.soap.SOAPHeaderBlock;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -19,6 +28,52 @@
public class AddressingSubmissionInHandler extends AddressingInHandler {
- private static final long serialVersionUID = 365417374773955107L;
+ private static final long serialVersionUID = 365417374773955107L;
+
+ public AddressingSubmissionInHandler() {
+ addressingNamespace = Submission.WSA_NAMESPACE;
+ addressingVersion = "WS-Addressing Submission";
+ }
+
+
+ protected void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader header) {
+ // there is no exact way to identify ref parameters for Submission version. So let's have a handler
+ // at the end of the flow, which puts all the handlers (which are of course mustUnderstand=false)
+ // as reference parameters
+
+ // TODO : Chinthaka
+ }
+
+ protected void extractEPRInformation(SOAPHeaderBlock headerBlock, EndpointReference epr, String addressingNamespace) {
+
+ Iterator childElements = headerBlock.getChildElements();
+ while (childElements.hasNext()) {
+ OMElement eprChildElement = (OMElement) childElements.next();
+ 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())) {
+
+ Iterator referenceParameters = eprChildElement.getChildElements();
+ while (referenceParameters.hasNext()) {
+ OMElement element = (OMElement) referenceParameters.next();
+ epr.addReferenceParameter(element);
+ }
+ } else
+ if (checkElement(new QName(addressingNamespace, AddressingConstants.Submission.EPR_REFERENCE_PROPERTIES)
+ , eprChildElement.getQName())) {
+
+ // since we have the model for WS-Final, we don't have a place to keep this reference properties.
+ // The only compatible place is reference properties
+ Iterator referenceParameters = eprChildElement.getChildElements();
+ while (referenceParameters.hasNext()) {
+ OMElement element = (OMElement) referenceParameters.next();
+ epr.addReferenceParameter(element);
+ }
+ }
+ }
+ }
}
Modified: webservices/axis2/trunk/java/modules/addressing/test-resources/OutHandlerTest.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test-resources/OutHandlerTest.xml?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/OutHandlerTest.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/OutHandlerTest.xml Tue Feb 7 02:28:00 2006
@@ -10,7 +10,6 @@
<wsa:MessageID>123456-7890</wsa:MessageID>
<myRef:Reference4>Value 400</myRef:Reference4>
<myRef:Reference3>Value 300</myRef:Reference3>
- <wsa:PortType>portNS:Port</wsa:PortType>
<wsa:Action>http://www.actions.org/action</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://www.replyTo.org/service/</wsa:Address>
Modified: webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml Tue Feb 7 02:28:00 2006
@@ -5,7 +5,6 @@
<wsa:Reference0>Value 0</wsa:Reference0>
<wsa:Reference2>Value 200</wsa:Reference2>
<wsa:Reference3>Value 300</wsa:Reference3>
- <wsa:PortType>portNS:Port</wsa:PortType>
<wsa:To>http://www.to.org/service/</wsa:To>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
Modified: webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml Tue Feb 7 02:28:00 2006
@@ -15,9 +15,6 @@
<wsa:Action>http://ws.apache.org/tests/action</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://example.com/fabrikam/acct</wsa:Address>
- <wsa:Metadata>
- <InterfaceName>fabrikam:Inventory</InterfaceName>
- </wsa:Metadata>
<wsa:ReferenceParameters>
<fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>
<fabrikam:ShoppingCart>ABCDEFG</fabrikam:ShoppingCart>
Modified: webservices/axis2/trunk/java/modules/addressing/test-resources/soapmessage.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test-resources/soapmessage.xml?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/soapmessage.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/soapmessage.xml Tue Feb 7 02:28:00 2006
@@ -13,9 +13,6 @@
<wsa:Action>http://ws.apache.org/tests/action</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://example.com/fabrikam/acct</wsa:Address>
- <wsa:Metadata>
- <InterfaceName>fabrikam:Inventory</InterfaceName>
- </wsa:Metadata>
<wsa:ReferenceParameters>
<fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>
<fabrikam:ShoppingCart>ABCDEFG</fabrikam:ShoppingCart>
Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTest.java?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTest.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTest.java Tue Feb 7 02:28:00 2006
@@ -50,7 +50,7 @@
protected void setUp() throws Exception {
super.setUp();
- inHandler = new AddressingInHandler();
+ inHandler = new AddressingFinalInHandler();
}
@@ -61,7 +61,7 @@
SOAPHeader header = ((SOAPEnvelope) omBuilder.getDocumentElement()).getHeader();
Options options =
- inHandler.extractCommonAddressingParameters(header,
+ inHandler.extractAddressingInformation(header,
new Options(),
header.getHeaderBlocksWithNSURI(
AddressingConstants.Submission.WSA_NAMESPACE),
@@ -100,7 +100,7 @@
inHandler.addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
SOAPHeader header = ((SOAPEnvelope) omBuilder.getDocumentElement()).getHeader();
Options options =
- inHandler.extractCommonAddressingParameters(header,
+ inHandler.extractAddressingInformation(header,
new Options(),
header.getHeaderBlocksWithNSURI(
AddressingConstants.Final.WSA_NAMESPACE),
Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java Tue Feb 7 02:28:00 2006
@@ -41,7 +41,7 @@
protected void setUp() throws Exception {
super.setUp();
- outHandler = new AddressingOutHandler();
+ outHandler = new AddressingFinalOutHandler();
testUtil = new TestUtil();
}
@@ -49,10 +49,6 @@
public void testAddToSOAPHeader() throws Exception {
EndpointReference replyTo = new EndpointReference("http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous");
EndpointReference epr = new EndpointReference("http://www.to.org/service/");
- epr.setPortType(
- new QName("http://www.from.org/service/port/",
- "Port",
- "portNS"));
for (int i = 0; i < 5; i++) {
epr.addReferenceParameter(
@@ -96,10 +92,6 @@
new QName("http://reference.org", "Reference3", "myRef"),
"Value 300");
- epr.setPortType(
- new QName("http://www.from.org/service/port/",
- "Port",
- "portNS"));
msgCtxt.setTo(epr);
epr =
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=375565&r1=375564&r2=375565&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 Feb 7 02:28:00 2006
@@ -70,9 +70,7 @@
public static final String WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE = "wsa:Reply";
public static final String WSA_ANONYMOUS_URL =
"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
- public static final String EPR_SERVICE_NAME_PORT_NAME = "PortName";
public static final String EPR_REFERENCE_PROPERTIES = "ReferenceProperties";
- public static final String EPR_PORT_TYPE = "PortType";
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java Tue Feb 7 02:28:00 2006
@@ -24,29 +24,36 @@
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.ArrayList;
/**
* Class EndpointReference
- * Contents of this class differs between WS-A Submission and WS-Final. Without having a
- * inheritance hierarchy for this small difference, lets have all the properties in the same class.
+ * This class models the WS-A EndpointReferenceType. But this can be used without any WS-A handlers as well
+ * Since the models for this in Submission and Final versions are different, lets make this to comply with
+ * WS-A Final version. So any information found with WS-A submission will be "pumped" in to this model.
*/
public class EndpointReference implements Serializable {
- private static final long serialVersionUID = 5278892171162372439L;
+ private static final long serialVersionUID = 5278892171162372439L;
- // Commons properties
- private String address;
+ /**
+ * <EndpointReference>
+ * <Address>xs:anyURI</Address>
+ * <ReferenceParameters>xs:any*</ReferenceParameters>
+ * <MetaData>xs:any*</MetaData>
+ * <!-- In addition to this, EPR can contain any number of OMElements -->
+ * </EndpointReference>
+ */
- // Properties from WS-A Final
+
+ private String address;
private OMElement metaData;
- private OMElement policy;
- private QName portType;
private Map referenceParameters;
+ private ArrayList omElements;
- // Properties from WS-A Submission version
- private Map referenceProperties;
/**
+ *
* @param address
*/
public EndpointReference(String address) {
@@ -60,11 +67,9 @@
if (omElement == null) {
return;
}
-
if (referenceParameters == null) {
referenceParameters = new HashMap();
}
-
referenceParameters.put(omElement.getQName(), omElement);
}
@@ -77,55 +82,12 @@
if (qname == null) {
return;
}
-
OMElement omElement = OMAbstractFactory.getOMFactory().createOMElement(qname, null);
-
omElement.setText(value);
addReferenceParameter(omElement);
}
/**
- * Remember that reference properties are only supported in WS-A Submission version.
- *
- * @param omElement
- */
- public void addReferenceProperty(OMElement omElement) {
- if (omElement == null) {
- return;
- }
-
- if (referenceProperties == null) {
- referenceProperties = new HashMap();
- }
-
- referenceProperties.put(omElement.getQName(), omElement);
- }
-
- /**
- * Remember that reference properties are only supported in WS-A Submission version.
- *
- * @param qname
- * @param value
- */
- public void addReferenceProperty(QName qname, String value) {
- if (qname == null) {
- return;
- }
-
- OMElement omElement = OMAbstractFactory.getOMFactory().createOMElement(qname, null);
-
- omElement.setText(value);
- addReferenceProperty(omElement);
- }
-
- /**
- * Method getAddress
- */
- public String getAddress() {
- return address;
- }
-
- /**
* This will return a Map of reference parameters with QName as the key and an OMElement
* as the value
*
@@ -136,48 +98,36 @@
return referenceParameters;
}
- /**
- * This will return a Map of reference properties with QName as the key and an OMElement
- * as the value
- *
- * @return - map of the reference parameters, where the key is the QName of the reference parameter
- * and the value is an OMElement
- */
- public Map getAllReferenceProperties() {
- return referenceProperties;
- }
-
- public OMElement getMetaData() {
- return metaData;
- }
-
- public OMElement getPolicy() {
- return policy;
- }
-
- public QName getPortType() {
- return portType;
+ public String getAddress() {
+ return address;
}
/**
- * Method setAddress
*
- * @param address
+ * @param address - xs:anyURI
*/
public void setAddress(String address) {
this.address = address;
}
- public void setMetaData(OMElement metaData) {
- this.metaData = metaData;
+ public ArrayList getOmElements() {
+ return omElements;
}
- public void setPolicy(OMElement policy) {
- this.policy = policy;
+ /**
+ * {any}
+ * @param omElements
+ */
+ public void setOmElements(ArrayList omElements) {
+ this.omElements = omElements;
+ }
+
+ public OMElement getMetaData() {
+ return metaData;
}
- public void setPortType(QName portType) {
- this.portType = portType;
+ public void setMetaData(OMElement metaData) {
+ this.metaData = metaData;
}
/**
@@ -190,13 +140,4 @@
this.referenceParameters = referenceParameters;
}
- /**
- * Set a Map with QName as the key and an OMElement
- * as the value
- *
- * @param referenceProperties
- */
- public void setReferenceProperties(HashMap referenceProperties) {
- this.referenceProperties = referenceProperties;
- }
}
Modified: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java?rev=375565&r1=375564&r2=375565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java (original)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java Tue Feb 7 02:28:00 2006
@@ -53,32 +53,6 @@
endpointReference.getAddress());
}
- public void testGetAndSetPortType() {
- QName portType = new QName("www.someport.com", "port");
- endpointReference.setPortType(portType);
- assertEquals("PortType not set/get properly",
- portType,
- endpointReference.getPortType());
- }
-
- public void testGetAndSetReferenceProperties() {
- for (int i = 0; i < 10; i++) {
- endpointReference.addReferenceProperty(
- new QName("http://www.opensouce.lk/" + i, "" + i),
- "value " + i * 100);
- }
-
- Map retrievedReferenceProperties = endpointReference.getAllReferenceProperties();
- for (int i = 0; i < 10; i++) {
- OMElement referenceProperty = (OMElement) retrievedReferenceProperties.get(new QName("http://www.opensouce.lk/" + i, "" + i));
- assertEquals(
- "Input value differs from what is taken out from AnyContentType",
- referenceProperty.getText(),
- "value " + i * 100);
- }
-
- }
-
public void testGetAndSetReferenceParameters() {
for (int i = 0; i < 10; i++) {
endpointReference.addReferenceParameter(