[jbossws-commits] JBossWS SVN: r3570 - branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/extensions/addressing/soap.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Jun 13 10:42:48 EDT 2007


Author: heiko.braun at jboss.com
Date: 2007-06-13 10:42:48 -0400 (Wed, 13 Jun 2007)
New Revision: 3570

Modified:
   branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
Log:
wsa:To is not a required element

Modified: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java	2007-06-13 14:31:02 UTC (rev 3569)
+++ branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java	2007-06-13 14:42:48 UTC (rev 3570)
@@ -23,7 +23,6 @@
 
 //$Id$
 
-import org.jboss.util.NotImplementedException;
 import org.jboss.ws.core.soap.NameImpl;
 import org.jboss.ws.core.soap.SOAPFactoryImpl;
 import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
@@ -53,6 +52,8 @@
  * read and write the Message Addressing Properties to a <code>SOAPMessage</code>.
  * All individual properties must implement <code>SOAPAddressingElement</code>.
  *
+ * @See http://www.w3.org/TR/ws-addr-core/
+ * 
  * @author Thomas.Diesler at jboss.org
  * @since 15-Nov-2005
  */
@@ -96,17 +97,12 @@
          AddressingConstants ADDR = builder.newAddressingConstants();
 		 registerNamespaces(ADDR, soapHeader);
    
-			// required elements
-			String action = getRequiredHeaderContent(soapHeader, ADDR.getActionQName());			
-			String to = getRequiredHeaderContent(soapHeader, ADDR.getToQName());			
-
-			// wsa:Action
-			// This REQUIRED element of type xs:anyURI conveys the [action] property.
-			// The [children] of this element convey the value of this property.
-			setAction(builder.newURI(action));
-
 			// wsa:To
-			// This REQUIRED element (of type xs:anyURI) provides the value for the [destination] property.
+			// This OPTIONAL element provides the value for the [destination] property.
+			// If this element is NOT present then the value of the [destination]
+			// property is "http://www.w3.org/2005/08/addressing/anonymous".
+			String to = getOptionalHeaderContent(soapHeader, ADDR.getToQName());			
+			if(to!=null)
 			setTo(builder.newURI(to));
 
 			// Read wsa:From
@@ -119,8 +115,9 @@
 			}
 
 			// Read wsa:ReplyTo
-			// This OPTIONAL element (of type wsa:EndpointReferenceType) provides the value for the [reply endpoint] property.
-			// This element MUST be present if a reply is expected. If this element is present, wsa:MessageID MUST be present.
+			// This OPTIONAL element provides the value for the [reply endpoint] property.
+			// If this element is NOT present then the value of the [address] property of the [reply endpoint]
+			// EPR is "http://www.w3.org/2005/08/addressing/anonymous".
 			Element wsaReplyTo = DOMUtils.getFirstChildElement(soapHeader, ADDR.getReplyToQName());
 			if (wsaReplyTo != null)
 			{
@@ -138,25 +135,20 @@
 				setFaultTo(ref);
 			}
 
+			// wsa:Action
+			// This REQUIRED element of type xs:anyURI conveys the [action] property.
+			// The [children] of this element convey the value of this property.
+			String action = getRequiredHeaderContent(soapHeader, ADDR.getActionQName());
+			setAction(builder.newURI(action));
+
 			// Read wsa:MessageID
-			// This OPTIONAL element conveys the [message id] property.
-			// This element MUST be present if wsa:ReplyTo or wsa:FaultTo is present.
-			if(wsaReplyTo!=null || wsaFaultTo!=null)
-			{
-				String msgIdValue = getRequiredHeaderContent(soapHeader, ADDR.getMessageIDQName());
-				setMessageID(builder.newURI(msgIdValue));
-			}
-			else
-			{
+			// This OPTIONAL element (whose content is of type xs:anyURI) conveys the [message id] property.
 				String messageID = getOptionalHeaderContent(soapHeader, ADDR.getMessageIDQName());
 				if(messageID!=null) setMessageID(builder.newURI(messageID));
-			}
 			
 			// Read wsa:RelatesTo
-			// This OPTIONAL (repeating) element information item contributes one abstract [relationship] property value,
-			// in the form of a (URI, QName) pair.
-			// The [children] property of this element (which is of type xs:anyURI) conveys the [message id]
-			// of the related message. This element MUST be present if the message is a reply.
+			// This OPTIONAL attribute conveys the relationship type as an IRI.
+			// When absent, the implied value of this attribute is "http://www.w3.org/2005/08/addressing/reply".
 			Iterator itRelatesTo = DOMUtils.getChildElements(soapHeader, ADDR.getRelatesToQName());
 			List<Relationship> relList = new ArrayList<Relationship>();
 			while (itRelatesTo.hasNext())
@@ -222,18 +214,15 @@
          SOAPFactoryImpl factory = (SOAPFactoryImpl)SOAPFactory.newInstance();
          SOAPHeader soapHeader = message.getSOAPHeader();
 
-			// Assert on REQUIRED elements wsa:Action and wsa:To
-         if (getAction() == null)
-				throw new AddressingException("Required addressing header missing: " + ADDR.getActionQName());
-			if (getTo() == null)
-				throw new AddressingException("Required addressing header missing: " + ADDR.getToQName());
-
          // Add the xmlns:wsa declaration 
          soapHeader.addNamespaceDeclaration(ADDR.getNamespacePrefix(), ADDR.getNamespaceURI());
 
-			// Write REQUIRED wsa:Action and wsa:To
-			appendRequiredHeader(soapHeader, ADDR.getActionQName(), getAction());
-			appendRequiredHeader(soapHeader, ADDR.getToQName(), getTo());
+			// Write wsa:To
+			if (getTo() != null)
+			{
+				SOAPElement element = soapHeader.addChildElement(new NameImpl(ADDR.getToQName()));
+				element.addTextNode(getTo().getURI().toString());
+			}
 
          // Write wsa:From
          if (getFrom() != null)
@@ -265,6 +254,8 @@
             soapHeader.addChildElement(soapElement);
          }
       
+			appendRequiredHeader(soapHeader, ADDR.getActionQName(), getAction());
+			
          // Write wsa:MessageID
 			if( (getReplyTo()!=null || getFaultTo()!=null) && null==getMessageID())
 			{
@@ -303,12 +294,15 @@
       }
       catch (SOAPException ex)
       {
-         throw new AddressingException("Cannot read headers", ex);
+			throw new AddressingException("Cannot read ws-addressing headers", ex);
       }
    }
 
 	private void appendRequiredHeader(SOAPHeader soapHeader, QName name, AttributedURI value) throws SOAPException
 	{
+		if(null == value)
+			throw new AddressingException("Required addressing property missing: " + name);
+		
 		SOAPElement element = soapHeader.addChildElement(new NameImpl(name));
 		element.addTextNode(value.getURI().toString());
 




More information about the jbossws-commits mailing list