[jboss-svn-commits] JBL Code SVN: r18036 - in labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing: soap and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 22 13:02:43 EST 2008


Author: adinn
Date: 2008-01-22 13:02:43 -0500 (Tue, 22 Jan 2008)
New Revision: 18036

Modified:
   labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
   labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
   labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
Log:
version used to build wsbrew.jar included in current (as of this checkin) .. /XTSGF tree which now works on glassfish

Modified: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java	2008-01-22 16:19:36 UTC (rev 18035)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java	2008-01-22 18:02:43 UTC (rev 18036)
@@ -27,10 +27,8 @@
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.BindingProvider;
 import javax.xml.ws.addressing.AddressingBuilder;
 import javax.xml.ws.addressing.AddressingException;
-import javax.xml.ws.addressing.AttributedURI;
 import javax.xml.ws.addressing.JAXWSAConstants;
 import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
 import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
@@ -38,6 +36,8 @@
 import javax.xml.ws.handler.MessageContext.Scope;
 import javax.xml.ws.handler.soap.SOAPHandler;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.io.OutputStream;
+import java.io.StringWriter;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -97,11 +97,16 @@
 	{
 		log.log(Level.INFO, "handleOutbound");
 
-		SOAPAddressingProperties addrProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
+        SOAPAddressingProperties addrProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
 		if (addrProps != null)
 		{
 			SOAPMessage soapMessage = msgContext.getMessage();
-			addrProps.writeHeaders(soapMessage);
+            addrProps.writeHeaders(soapMessage);
+
+            try {
+                soapMessage.writeTo(System.out);
+            } catch (Exception e) {
+            }
         }
 		else
 		{

Modified: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java	2008-01-22 16:19:36 UTC (rev 18035)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java	2008-01-22 18:02:43 UTC (rev 18036)
@@ -139,6 +139,12 @@
 		}
 
 		outProps.initializeAsReply(inProps, isFault);
+
+
+        try {
+            soapMessage.writeTo(System.out);
+        } catch (Exception e) {
+        }
         /*
          * cannot do this bit but we don't care
 		try

Modified: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java	2008-01-22 16:19:36 UTC (rev 18035)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java	2008-01-22 18:02:43 UTC (rev 18036)
@@ -195,53 +195,113 @@
 
             // Add the xmlns:wsa declaration
 			soapHeader.addNamespaceDeclaration(ADDR.getNamespacePrefix(), ADDR.getNamespaceURI());
-						
-			// Write wsa:To
+
+            Iterator iter;
+
+            // Write wsa:To
 			if (getTo() != null)
 			{
-				SOAPElement element = soapHeader.addChildElement(ADDR.getToQName());
-				element.addTextNode(getTo().getURI().toString());
-			}
+                // To header may already be present -- ensure it is the same
+                iter = soapHeader.getChildElements(ADDR.getToQName());
+                if (iter.hasNext()) {
+                    String toAddress = getTo().getURI().toString();
+                    SOAPElement element =(SOAPElement)iter.next();
+                    if (!element.getTextContent().equals(toAddress)) {
+                        throw new AddressingException("Invalid To: header in addressing properties : " + toAddress);
+                    }
+                } else {
+                    SOAPElement element = soapHeader.addChildElement(ADDR.getToQName());
+                    element.addTextNode(getTo().getURI().toString());
+                }
+            }
 
 			// Write wsa:From
 			if (getFrom() != null)
 			{
-				EndpointReferenceImpl epr = (EndpointReferenceImpl)getFrom();
-				epr.setRootQName(ADDR.getFromQName());
-				SOAPElement soapElement = factory.createElement(epr.toElement());
-				soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
-				soapHeader.addChildElement(soapElement);
-			}
+                // From header may already be present -- ensure it is the same
+                iter = soapHeader.getChildElements(ADDR.getFromQName());
+                if (iter.hasNext()) {
+                    String fromAddress = getFrom().getAddress().getURI().toString();
+                    SOAPElement element =(SOAPElement)iter.next();
+                    if (!element.getTextContent().equals(fromAddress)) {
+                        throw new AddressingException("Invalid From: header in addressing properties : " + fromAddress);
+                    }
+                } else {
+                    EndpointReferenceImpl epr = (EndpointReferenceImpl)getFrom();
+                    epr.setRootQName(ADDR.getFromQName());
+                    SOAPElement soapElement = factory.createElement(epr.toElement());
+                    soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
+                    soapHeader.addChildElement(soapElement);
+                }
+            }
 
-			// Write wsa:ReplyTo
+            // Write wsa:ReplyTo
 			if (getReplyTo() != null)
 			{
-				EndpointReferenceImpl epr = (EndpointReferenceImpl)getReplyTo();
-				epr.setRootQName(ADDR.getReplyToQName());
-				SOAPElement soapElement = factory.createElement(epr.toElement());
-				soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
-				soapHeader.addChildElement(soapElement);
-			}
+                // ReplyTo header may already be present -- ensure it is the same
+                iter = soapHeader.getChildElements(ADDR.getReplyToQName());
+                if (iter.hasNext()) {
+                    String replyToAddress = getReplyTo().getAddress().getURI().toString();
+                    SOAPElement element =(SOAPElement)iter.next();
+                    if (!element.getTextContent().equals(replyToAddress)) {
+                        throw new AddressingException("Invalid ReplyTo: header in addressing properties : " + replyToAddress);
+                    }
+                } else {
+                    EndpointReferenceImpl epr = (EndpointReferenceImpl)getReplyTo();
+                    epr.setRootQName(ADDR.getReplyToQName());
+                    SOAPElement soapElement = factory.createElement(epr.toElement());
+                    soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
+                    soapHeader.addChildElement(soapElement);
+                }
+            }
 
-			// Write wsa:FaultTo
+            // Write wsa:FaultTo
 			if (getFaultTo() != null)
 			{
-				EndpointReferenceImpl epr = (EndpointReferenceImpl)getFaultTo();
-				epr.setRootQName(ADDR.getFaultToQName());
-				SOAPElement soapElement = factory.createElement(epr.toElement());
-				soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
-				soapHeader.addChildElement(soapElement);
-			}
+                // FaultTo header may already be present -- ensure it is the same
+                iter = soapHeader.getChildElements(ADDR.getFaultToQName());
+                if (iter.hasNext()) {
+                    String faultToAddress = getReplyTo().getAddress().getURI().toString();
+                    SOAPElement element =(SOAPElement)iter.next();
+                    if (!element.getTextContent().equals(faultToAddress)) {
+                        throw new AddressingException("Invalid FaultTo: header in addressing properties : " + faultToAddress);
+                    }
+                } else {
+                    EndpointReferenceImpl epr = (EndpointReferenceImpl)getFaultTo();
+                    epr.setRootQName(ADDR.getFaultToQName());
+                    SOAPElement soapElement = factory.createElement(epr.toElement());
+                    soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
+                    soapHeader.addChildElement(soapElement);
+                }
+            }
 
-			appendRequiredHeader(soapHeader, ADDR.getActionQName(), getAction());
-			
-			// Write wsa:MessageID
+            // Action header may already be present -- ensure it is the same
+			iter = soapHeader.getChildElements(ADDR.getActionQName());
+            if (iter.hasNext()) {
+                String action = getAction().getURI().toString();
+                SOAPElement element =(SOAPElement)iter.next();
+                if (!element.getTextContent().equals(action)) {
+                    throw new AddressingException("Invalid Action: header in addressing properties : " + action);
+                }
+            } else {
+                appendRequiredHeader(soapHeader, ADDR.getActionQName(), getAction());
+            }
+
+            // Write wsa:MessageID
 			if( (getReplyTo()!=null || getFaultTo()!=null) && null==getMessageID())
 			{
 				throw new AddressingException("Required addressing header missing:" + ADDR.getMessageIDQName());
 			}
 			else if (getMessageID() != null)
 			{
+                // messageID header may already be present -- if so override it using the one supplied in the
+                // addressing properties -- we need to be able to wait on the reply using our rather than the
+                // one supplied by the Glassfish WS Addressing code
+                iter = soapHeader.getChildElements(ADDR.getMessageIDQName());
+                if (iter.hasNext()) {
+                    SOAPElement element =(SOAPElement)iter.next();
+                    soapHeader.removeChild(element);
+                }
 				SOAPElement wsaMessageId = soapHeader.addChildElement(ADDR.getMessageIDQName());
 				wsaMessageId.addTextNode(getMessageID().getURI().toString());
 			}
@@ -249,19 +309,47 @@
 			// Write wsa:RelatesTo
 			if (getRelatesTo() != null)
 			{
-				for (Relationship rel : getRelatesTo())
-				{
-					SOAPElement wsaRelatesTo = soapHeader.addChildElement(ADDR.getRelatesToQName());
-					if (rel.getType() != null)
-					{
-						wsaRelatesTo.setAttribute(ADDR.getRelationshipTypeName(), getPrefixedName(rel.getType()));
-					}
-					wsaRelatesTo.addTextNode(rel.getID().toString());
-				}
-			}
+                // relatesTo header may already be present -- if so only add relationships which are not already present
+                for (Relationship rel : getRelatesTo())
+                {
+                    boolean present = false;
+                    String idString = rel.getID().toString();
+                    QName type = rel.getType();
+                    String typeName = (type == null ? "" : getPrefixedName(type));
 
+                    iter = soapHeader.getChildElements(ADDR.getRelatesToQName());
+                    while (!present && iter.hasNext()) {
+                        SOAPElement wsaRelatesTo = (SOAPElement)iter.next();
+                        // are the relationship types are both the same
+                        String typeName2 = wsaRelatesTo.getAttribute(ADDR.getRelationshipTypeName());
+                        if (typeName.equals(typeName2)) {
+                            // are the relationsip text values the same
+                            String idString2 = wsaRelatesTo.getTextContent();
+                            if (idString.equals(idString2)) {
+                                present = true;
+                            } else {
+                                // duplicated type qwith different value!
+                                throw new AddressingException("Invalid RelatesTo:" + typeName + " header in addressing properties : " + idString);
+                            }
+                        }
+                    }
+                    if (!present) {
+                        SOAPElement wsaRelatesTo = soapHeader.addChildElement(ADDR.getRelatesToQName());
+                        if (type != null)
+                        {
+                            wsaRelatesTo.setAttribute(ADDR.getRelationshipTypeName(), getPrefixedName(rel.getType()));
+                        }
+                        wsaRelatesTo.addTextNode(idString);
+                    }
+                }
+            }
+
 			// Write wsa:ReferenceParameters
-			ReferenceParameters refParams = getReferenceParameters();
+
+            // hmm, we probably need to worry about duplicates here from client code but we are not using this
+            // for the XTS code so ignore it for now
+
+            ReferenceParameters refParams = getReferenceParameters();
 			if (refParams.getElements().size() > 0 || refParams.getAttributes().size() > 0)
 			{
 				SOAPElement wsaRefParams = soapHeader.addChildElement(ADDR.getReferenceParametersQName());




More information about the jboss-svn-commits mailing list