axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r289209 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/ addressing/test-resources/ addressing/test/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/addressing/ core/src/org/apa...
Date Thu, 15 Sep 2005 11:37:46 GMT
Author: chinthaka
Date: Thu Sep 15 04:37:10 2005
New Revision: 289209

URL: http://svn.apache.org/viewcvs?rev=289209&view=rev
Log:
Addressing in handler will now pick up the reference parameters from the in message. Need
to add at least one test case for this.
Have some more stuff to be done in the addressing stuff ...

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    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/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/src/org/apache/axis2/util/Utils.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=289209&r1=289208&r2=289209&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
Thu Sep 15 04:37:10 2005
@@ -2,6 +2,7 @@
 
 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.miheaders.RelatesTo;
@@ -65,17 +66,17 @@
             if (addressingHeaders != null) {
                 addressingNamespace = Submission.WSA_NAMESPACE;
                 extractAddressingSubmissionInformationFromHeaders(
-                    header,
-                    msgContext.getMessageInformationHeaders(),
-                    addressingHeaders);
+                        header,
+                        msgContext.getMessageInformationHeaders(),
+                        addressingHeaders);
             } else {
                 addressingHeaders = header.getHeaderBlocksWithNSURI(Final.WSA_NAMESPACE);
                 if (addressingHeaders != null) {
                     addressingNamespace = Final.WSA_NAMESPACE;
                     extractAddressingFinalInformationFromHeaders(
-                        header,
-                        msgContext.getMessageInformationHeaders(),
-                        addressingHeaders);
+                            header,
+                            msgContext.getMessageInformationHeaders(),
+                            addressingHeaders);
                     extractReferenceParameters(header, msgContext.getMessageInformationHeaders());
 
                 } else {
@@ -84,7 +85,7 @@
                         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.");
+                            "No Addressing Headers present in the IN message. Addressing
In Handler does nothing.");
                 }
             }
             msgContext.setProperty(WS_ADDRESSING_VERSION, addressingNamespace, true);
@@ -103,55 +104,55 @@
      * @param messageInformationHeaders
      */
     private void extractReferenceParameters(
-        SOAPHeader header,
-        MessageInformationHeaders messageInformationHeaders) {
+            SOAPHeader header,
+            MessageInformationHeaders messageInformationHeaders) {
         Iterator headerBlocks = header.getChildren();
         while (headerBlocks.hasNext()) {
             SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) headerBlocks.next();
             if (Final
-                .WSA_TYPE_ATTRIBUTE_VALUE
-                .equals(
-                    soapHeaderBlock
-                        .getFirstAttribute(
-                            new QName(
-                                Final.WSA_NAMESPACE,
-                                Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE))
-                        .getValue())) {
+                    .WSA_TYPE_ATTRIBUTE_VALUE
+                    .equals(
+                            soapHeaderBlock
+                                    .getFirstAttribute(
+                                            new QName(
+                                                    Final.WSA_NAMESPACE,
+                                                    Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE))
+                                    .getValue())) {
                 messageInformationHeaders.addReferenceParameter(soapHeaderBlock);
             }
         }
     }
 
     private void extractAddressingFinalInformationFromHeaders(
-        SOAPHeader header,
-        MessageInformationHeaders messageInformationHeaders,
-        ArrayList addressingHeaders)
-        throws AddressingException {
+            SOAPHeader header,
+            MessageInformationHeaders messageInformationHeaders,
+            ArrayList addressingHeaders)
+            throws AddressingException {
         extractCommonAddressingParameters(
-            header,
-            messageInformationHeaders,
-            addressingHeaders,
-            Final.WSA_NAMESPACE);
+                header,
+                messageInformationHeaders,
+                addressingHeaders,
+                Final.WSA_NAMESPACE);
     }
 
     private void extractAddressingSubmissionInformationFromHeaders(
-        SOAPHeader header,
-        MessageInformationHeaders messageInformationHeaders,
-        ArrayList addressingHeaders)
-        throws AddressingException {
+            SOAPHeader header,
+            MessageInformationHeaders messageInformationHeaders,
+            ArrayList addressingHeaders)
+            throws AddressingException {
         extractCommonAddressingParameters(
-            header,
-            messageInformationHeaders,
-            addressingHeaders,
-            Submission.WSA_NAMESPACE);
+                header,
+                messageInformationHeaders,
+                addressingHeaders,
+                Submission.WSA_NAMESPACE);
     }
 
     public MessageInformationHeaders extractCommonAddressingParameters(
-        SOAPHeader header,
-        MessageInformationHeaders messageInformationHeaders,
-        ArrayList addressingHeaders,
-        String addressingNamespace)
-        throws AddressingException {
+            SOAPHeader header,
+            MessageInformationHeaders messageInformationHeaders,
+            ArrayList addressingHeaders,
+            String addressingNamespace)
+            throws AddressingException {
         if (messageInformationHeaders == null) {
             messageInformationHeaders = new MessageInformationHeaders();
         }
@@ -170,21 +171,21 @@
                     epr = new EndpointReference("");
                     messageInformationHeaders.setFrom(epr);
                 }
-                extractEPRAddressInformation(soapHeaderBlock, epr, addressingNamespace);
+                extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
             } else if (AddressingConstants.WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName()))
{
                 epr = messageInformationHeaders.getReplyTo();
                 if (epr == null) {
                     epr = new EndpointReference("");
                     messageInformationHeaders.setReplyTo(epr);
                 }
-                extractEPRAddressInformation(soapHeaderBlock, epr, addressingNamespace);
+                extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
             } else if (AddressingConstants.WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName()))
{
                 epr = messageInformationHeaders.getFaultTo();
                 if (epr == null) {
                     epr = new EndpointReference("");
                     messageInformationHeaders.setFaultTo(epr);
                 }
-                extractEPRAddressInformation(soapHeaderBlock, epr, addressingNamespace);
+                extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
             } else if (AddressingConstants.WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName()))
{
                 messageInformationHeaders.setMessageId(soapHeaderBlock.getText());
             } else if (AddressingConstants.WSA_ACTION.equals(soapHeaderBlock.getLocalName()))
{
@@ -192,18 +193,18 @@
             } else if (AddressingConstants.WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName()))
{
                 String address = soapHeaderBlock.getText();
                 OMAttribute relationshipType =
-                    soapHeaderBlock.getFirstAttribute(
-                        new QName(AddressingConstants.WSA_RELATES_TO_RELATIONSHIP_TYPE));
+                        soapHeaderBlock.getFirstAttribute(
+                                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;
+                        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.getValue());
+                        new RelatesTo(
+                                address,
+                                relationshipType == null
+                                        ? relationshipTypeDefaultValue
+                                        : relationshipType.getValue());
                 messageInformationHeaders.setRelatesTo(relatesTo);
             }
         }
@@ -211,16 +212,48 @@
         return messageInformationHeaders;
     }
 
-    private void extractEPRAddressInformation(
-        SOAPHeaderBlock headerBlock,
-        EndpointReference epr,
-        String addressingNamespace) {
-        OMElement address =
-            headerBlock.getFirstChildWithName(
-                new QName(addressingNamespace, AddressingConstants.EPR_ADDRESS));
-        if (address != null) {
-            epr.setAddress(address.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())){
+                AnyContentType anyContentType = new AnyContentType();
+                if(epr.getReferenceParameters() == null){
+                    epr.setReferenceParameters(anyContentType);
+                }
+                Iterator referenceParameters = eprChildElement.getChildElements();
+                while (referenceParameters.hasNext()) {
+                    OMElement element = (OMElement) referenceParameters.next();
+                    epr.getReferenceParameters().addReferenceValue(element.getQName(), element.getText());
+                }
+            } else if (checkElement(new QName(addressingNamespace, AddressingConstants.Final.WSA_METADATA),
eprChildElement.getQName())){
+                AnyContentType anyContentType = new AnyContentType();
+                if(epr.getMetadata() == null){
+                    epr.setMetadata(anyContentType);
+                }
+                Iterator metadataChildren = eprChildElement.getChildElements();
+                while (metadataChildren.hasNext()) {
+                    OMElement element = (OMElement) metadataChildren.next();
+                    epr.getMetadata().addReferenceValue(element.getQName(), element.getText());
+                }
+            }
         }
+//        OMElement address =
+//                headerBlock.getFirstChildWithName(
+//                        new QName(addressingNamespace, AddressingConstants.EPR_ADDRESS));
+//        if (address != null) {
+//            epr.setAddress(address.getText());
+//        }
+
+    }
 
+    private boolean checkElement(QName expectedQName, QName actualQName) {
+        return (expectedQName.getLocalPart().equals(actualQName.getLocalPart()) &&
expectedQName.getNamespaceURI().equals(actualQName.getNamespaceURI()));
     }
 }

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=289209&r1=289208&r2=289209&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/soapmessage.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/soapmessage.xml Thu Sep
15 04:37:10 2005
@@ -1,16 +1,35 @@
-<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
-    <soapenv:Header>
-        <wsa:MessageID soapenv:mustUnderstand="0">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                  xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
+    <soapenv:Header xmlns:fabrikam="http://example.com/fabrikam">
+        <wsa:MessageID soapenv:mustUnderstand="0">
+            uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID>
         <wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To>
         <wsa:From soapenv:mustUnderstand="0">
-            <wsa:Address>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
+            <wsa:Address>
+                http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
         </wsa:From>
         <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>
+            </wsa:ReferenceParameters>
+        </wsa:ReplyTo>
     </soapenv:Header>
     <soapenv:Body>
-        <ns1:getBalance soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://localhost:8081/axis/services/BankPort">
+        <ns1:getBalance soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+                        xmlns:ns1="http://localhost:8081/axis/services/BankPort">
             <accountNo href="#id0"/>
         </ns1:getBalance>
-        <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1001</multiRef>
+        <multiRef id="id0" soapenc:root="0"
+                  soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+                  xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
+            1001</multiRef>
     </soapenv:Body>
 </soapenv:Envelope>

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=289209&r1=289208&r2=289209&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
Thu Sep 15 04:37:10 2005
@@ -74,12 +74,13 @@
                     messageInformationHeaders.getAction(),
                     action);
             assertEquals("action header is not correct",
-                    messageInformationHeaders.getMessageId(),
-                    messageID);
+                    messageInformationHeaders.getMessageId().trim(),
+                    messageID.trim());
 
             assertFromEPR(messageInformationHeaders.getFrom());
 
         } catch (Exception e) {
+            e.printStackTrace();
             log.info(e.getMessage());
             fail(" An Exception has occured " + e.getMessage());
         }
@@ -87,8 +88,8 @@
 
     private void assertFromEPR(EndpointReference fromEPR) {
         assertEquals("Address in EPR is not valid",
-                fromEPR.getAddress(),
-                fromAddress);
+                fromEPR.getAddress().trim(),
+                fromAddress.trim());
     }
 
 

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=289209&r1=289208&r2=289209&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
Thu Sep 15 04:37:10 2005
@@ -63,6 +63,7 @@
         public static final String WSA_INTERFACE_NAME = "InterfaceName";
         public static final String WSA_SERVICE_NAME_ENDPOINT_NAME = "EndpointName";
         public static final String WSA_POLICIES = "Policies";
+        public static final String WSA_METADATA = "Metadata";
         // ==================================================================================
 
     }

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=289209&r1=289208&r2=289209&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
Thu Sep 15 04:37:10 2005
@@ -15,11 +15,10 @@
  */
 package org.apache.axis2.addressing;
 
-import java.io.Serializable;
-
 import org.apache.axis2.om.OMElement;
 
 import javax.xml.namespace.QName;
+import java.io.Serializable;
 
 /**
  * Class EndpointReference
@@ -53,6 +52,8 @@
 
     private OMElement policies;
 
+    private AnyContentType metadata;
+
     /**
      * @param address
      */
@@ -156,6 +157,14 @@
 
     public void setPolicies(OMElement policies) {
         this.policies = policies;
+    }
+
+    public AnyContentType getMetadata() {
+        return metadata;
+    }
+
+    public void setMetadata(AnyContentType metadata) {
+        this.metadata = metadata;
     }
 
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java?rev=289209&r1=289208&r2=289209&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java Thu Sep
15 04:37:10 2005
@@ -201,8 +201,7 @@
         ServiceGroupContext serviceGroupContext = new ServiceGroupContext(configurationContext,serviceDesc.getParent());
         serviceGroupContext.setId(serviceGroupContextId);
         configurationContext.registerServiceGroupContext(serviceGroupContext);
-        ServiceContext serviceContext = new ServiceContext(serviceDesc, serviceGroupContext);
-        return serviceContext;
+        return new ServiceContext(serviceDesc, serviceGroupContext);
     }
 
     public static ConfigurationContext getNewConfigurationContext(String repositry) throws
Exception {



Mime
View raw message