Author: alex.guizar(a)jboss.com
Date: 2007-03-13 06:59:34 -0400 (Tue, 13 Mar 2007)
New Revision: 2606
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/Constants.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java
Log:
JBCTS-467 reimplemented attribute accessor methods to be compatible with both SOAP 1.1 and
SOAP 1.2
Modified: trunk/jbossws-core/src/java/org/jboss/ws/Constants.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/Constants.java 2007-03-13 10:56:57 UTC (rev
2605)
+++ trunk/jbossws-core/src/java/org/jboss/ws/Constants.java 2007-03-13 10:59:34 UTC (rev
2606)
@@ -135,8 +135,6 @@
/** SOAP-1.1 attributes */
static final String SOAP11_ATTR_ACTOR = "actor";
- static final String SOAP12_ATTR_ROLE = "role";
- static final String SOAP12_ATTR_RELAY = "relay";
static final String SOAP11_ATTR_MUST_UNDERSTAND = "mustUnderstand";
/** SOAP-1.1 fault codes */
@@ -155,6 +153,10 @@
static final QName SOAP11_FAULTACTOR = new QName("faultactor");
static final QName SOAP11_DETAIL = new QName("detail");
+ /** SOAP-1.2 attributes */
+ static final String SOAP12_ATTR_ROLE = "role";
+ static final String SOAP12_ATTR_RELAY = "relay";
+
/**SOAP-1.2 elements */
static final QName SOAP12_CODE = new QName(NS_SOAP12_ENV, "Code",
PREFIX_ENV);
static final QName SOAP12_VALUE = new QName(NS_SOAP12_ENV, "Value",
PREFIX_ENV);
@@ -299,7 +301,6 @@
static final QName WSDL_ATTRIBUTE_WSA_ACTION = new QName(URI_WS_ADDRESSING,
"Action");
static final QName WSDL_ATTRIBUTE_WSE_EVENTSOURCE = new QName(URI_WS_EVENTING,
"EventSource");
-
/** WSDL-2.0 exchange patterns */
static final String WSDL20_PATTERN_IN_ONLY =
"http://www.w3.org/2004/08/wsdl/in-only";
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java 2007-03-13
10:56:57 UTC (rev 2605)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java 2007-03-13
10:59:34 UTC (rev 2606)
@@ -28,6 +28,7 @@
import java.util.Iterator;
import java.util.List;
+import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
@@ -36,6 +37,8 @@
import javax.xml.soap.SOAPHeaderElement;
import org.jboss.ws.Constants;
+import org.jboss.ws.core.utils.DOMUtils;
+import org.w3c.dom.Attr;
/**
* An object representing the contents in the SOAP header part of the SOAP envelope.
@@ -53,6 +56,11 @@
super(name);
}
+ public SOAPHeaderElementImpl(QName qname)
+ {
+ super(qname);
+ }
+
public SOAPHeaderElementImpl(SOAPElementImpl element)
{
super(element);
@@ -60,58 +68,82 @@
public String getRole()
{
- String envURI = Constants.NS_SOAP12_ENV;
- String attr = getAttributeNS(envURI, Constants.SOAP12_ATTR_ROLE);
- return attr;
+ final String headerURI = getParentElement().getNamespaceURI();
+
+ if (Constants.NS_SOAP11_ENV.equals(headerURI))
+ throw new UnsupportedOperationException("SOAP 1.1 does not support the
concept of Role");
+
+ Attr roleAttr = getAttributeNodeNS(headerURI, Constants.SOAP12_ATTR_ROLE);
+ return roleAttr != null ? roleAttr.getValue() : null;
}
public void setRole(String roleURI)
{
- String envURI = Constants.NS_SOAP12_ENV;
- String qualifiedName = Constants.PREFIX_ENV + ":" +
Constants.SOAP12_ATTR_ROLE;
- setAttributeNS(envURI, qualifiedName, roleURI);
+ final SOAPElement header = getParentElement();
+ final String headerURI = header.getNamespaceURI();
+
+ if (Constants.NS_SOAP11_ENV.equals(headerURI))
+ throw new UnsupportedOperationException("SOAP 1.1 does not support the
concept of Role");
+
+ setAttributeNS(headerURI, header.getPrefix() + ":" +
Constants.SOAP12_ATTR_ROLE, roleURI);
}
public boolean getRelay()
{
- String envURI = Constants.NS_SOAP12_ENV;
- String attr = getAttributeNS(envURI, Constants.SOAP12_ATTR_RELAY);
- return "true".equals(attr);
+ final String headerURI = getParentElement().getNamespaceURI();
+
+ if (Constants.NS_SOAP11_ENV.equals(headerURI))
+ throw new UnsupportedOperationException("SOAP 1.1 does not support the
concept of Role");
+
+ return DOMUtils.getAttributeValueAsBoolean(this, new QName(headerURI,
Constants.SOAP12_ATTR_RELAY));
}
public void setRelay(boolean relay)
{
- String envURI = Constants.NS_SOAP12_ENV;
- String qualifiedName = Constants.PREFIX_ENV + ":" +
Constants.SOAP12_ATTR_RELAY;
- setAttributeNS(envURI, qualifiedName, new Boolean(relay).toString());
+ final SOAPElement header = getParentElement();
+ final String headerURI = header.getNamespaceURI();
+
+ if (Constants.NS_SOAP11_ENV.equals(headerURI))
+ throw new UnsupportedOperationException("SOAP 1.1 does not support the
concept of Role");
+
+ setAttributeNS(headerURI, header.getPrefix() + ":" +
Constants.SOAP12_ATTR_RELAY, Boolean.toString(relay));
}
public String getActor()
{
- String envURI = Constants.NS_SOAP11_ENV;
- String attr = getAttributeNS(envURI, Constants.SOAP11_ATTR_ACTOR);
- return attr;
+ final String headerURI = getParentElement().getNamespaceURI();
+
+ if (!Constants.NS_SOAP11_ENV.equals(headerURI))
+ return getRole();
+
+ Attr actorAttr = getAttributeNodeNS(headerURI, Constants.SOAP11_ATTR_ACTOR);
+ return actorAttr != null ? actorAttr.getValue() : null;
}
- public boolean getMustUnderstand()
+ public void setActor(String actorURI)
{
- String envURI = Constants.NS_SOAP11_ENV;
- String attr = getAttributeNS(envURI, Constants.SOAP11_ATTR_MUST_UNDERSTAND);
- return "1".equals(attr);
+ final SOAPElement header = getParentElement();
+ final String headerURI = header.getNamespaceURI();
+
+ if (Constants.NS_SOAP11_ENV.equals(headerURI))
+ setAttributeNS(headerURI, header.getPrefix() + ":" +
Constants.SOAP11_ATTR_ACTOR, actorURI);
+ else
+ setRole(actorURI);
}
- public void setActor(String actorURI)
+ public boolean getMustUnderstand()
{
- String envURI = Constants.NS_SOAP11_ENV;
- String qualifiedName = Constants.PREFIX_ENV + ":" +
Constants.SOAP11_ATTR_ACTOR;
- setAttributeNS(envURI, qualifiedName, actorURI);
+ final String headerURI = getParentElement().getNamespaceURI();
+
+ return DOMUtils.getAttributeValueAsBoolean(this, new QName(headerURI,
Constants.SOAP11_ATTR_MUST_UNDERSTAND));
}
public void setMustUnderstand(boolean mustUnderstand)
{
- String envURI = Constants.NS_SOAP11_ENV;
- String qualifiedName = Constants.PREFIX_ENV + ":" +
Constants.SOAP11_ATTR_MUST_UNDERSTAND;
- setAttributeNS(envURI, qualifiedName, mustUnderstand ? "1" :
"0");
+ final SOAPElement header = getParentElement();
+ final String headerURI = header.getNamespaceURI();
+
+ setAttributeNS(headerURI, header.getPrefix() + ":" +
Constants.SOAP11_ATTR_MUST_UNDERSTAND, mustUnderstand ? "1" : "0");
}
public void setParentElement(SOAPElement parent) throws SOAPException