Author: thomas.diesler(a)jboss.com
Date: 2006-12-14 10:56:18 -0500 (Thu, 14 Dec 2006)
New Revision: 1653
Modified:
trunk/src/main/java/javax/xml/soap/SAAJResult.java
trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java
trunk/src/main/java/org/jboss/ws/Constants.java
trunk/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SchemaBindingBuilder.java
trunk/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java
trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java
Log:
Implement SAAJResult and SOAPHeaderElement stuff
Modified: trunk/src/main/java/javax/xml/soap/SAAJResult.java
===================================================================
--- trunk/src/main/java/javax/xml/soap/SAAJResult.java 2006-12-14 15:23:08 UTC (rev 1652)
+++ trunk/src/main/java/javax/xml/soap/SAAJResult.java 2006-12-14 15:56:18 UTC (rev 1653)
@@ -25,7 +25,7 @@
import javax.xml.transform.dom.DOMResult;
-import org.jboss.util.NotImplementedException;
+import org.w3c.dom.Element;
/**
* Acts as a holder for the results of a JAXP transformation or a JAXB marshalling, in
the form of a SAAJ tree.
@@ -36,6 +36,8 @@
*/
public class SAAJResult extends DOMResult
{
+ private SOAPElement rootElement;
+
/**
* Creates a SAAJResult that will present results in the form of a SAAJ tree that
supports the default (SOAP 1.1) protocol.
*
@@ -43,13 +45,12 @@
* takes a parameter whose type, such as SOAPElement, is drawn from the SAAJ API. When
used in a transformation,
* the results are populated into the SOAPPart of a SOAPMessage that is created
internally.
* The SOAPPart returned by DOMResult.getNode() is not guaranteed to be well-formed.
+ *
* @throws SOAPException if there is a problem creating a SOAPMessage
* @since SAAJ 1.3
*/
public SAAJResult() throws SOAPException
{
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
}
/**
@@ -64,8 +65,6 @@
*/
public SAAJResult(String protocol) throws SOAPException
{
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
}
/**
@@ -79,8 +78,14 @@
*/
public SAAJResult(SOAPMessage message)
{
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
+ try
+ {
+ rootElement = message.getSOAPPart().getEnvelope();
+ }
+ catch (SOAPException ex)
+ {
+ throw new IllegalArgumentException("Cannot create SAAJ result", ex);
+ }
}
/**
@@ -93,8 +98,7 @@
*/
public SAAJResult(SOAPElement rootNode)
{
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
+ rootElement = rootNode;
}
/**
@@ -103,7 +107,24 @@
*/
public Node getResult()
{
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
+ return rootElement;
}
+
+ public void setNode(org.w3c.dom.Node node)
+ {
+ rootElement = null;
+ if (node instanceof Element)
+ {
+ try
+ {
+ SOAPFactory factory = SOAPFactory.newInstance();
+ rootElement = factory.createElement((Element)node);
+ }
+ catch (SOAPException ex)
+ {
+ throw new IllegalArgumentException("Cannot set node: " + node,
ex);
+ }
+ }
+ }
}
+
Modified: trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java
===================================================================
--- trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java 2006-12-14 15:23:08 UTC (rev
1652)
+++ trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java 2006-12-14 15:56:18 UTC (rev
1653)
@@ -72,8 +72,18 @@
* @throws UnsupportedOperationException if this message does not support the SOAP 1.2
concept of Fault Role.
* @since SAAJ 1.3
*/
- public boolean getRole();
+ public String getRole();
+ /**
+ * Sets the Role associated with this SOAPHeaderElement object to the specified
Role.
+ *
+ * @param roleURI the URI of the Role
+ * @throws SOAPException if there is an error in setting the role
+ * @throws UnsupportedOperationException if this message does not support the SOAP 1.2
concept of Fault Role
+ * @since SAAJ 1.3
+ */
+ public void setRole(String roleURI);
+
/** Sets the actor associated with this SOAPHeaderElement object to the specified
actor.
* The default value of an actor is: SOAPConstants.URI_SOAP_ACTOR_NEXT
*
Modified: trunk/src/main/java/org/jboss/ws/Constants.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/Constants.java 2006-12-14 15:23:08 UTC (rev 1652)
+++ trunk/src/main/java/org/jboss/ws/Constants.java 2006-12-14 15:56:18 UTC (rev 1653)
@@ -123,7 +123,8 @@
/** SOAP-1.1 attributes */
static final String SOAP11_ATTR_ACTOR = "actor";
- static final String SOAP11_ATTR_ROLE = "role";
+ 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 */
Modified:
trunk/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SchemaBindingBuilder.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SchemaBindingBuilder.java 2006-12-14
15:23:08 UTC (rev 1652)
+++
trunk/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SchemaBindingBuilder.java 2006-12-14
15:56:18 UTC (rev 1653)
@@ -246,7 +246,7 @@
// attributeFormDefault="qualified"
String nsURI = typeBinding.getQName().getNamespaceURI();
if (Constants.SOAP11_ATTR_MUST_UNDERSTAND.equals(xmlAttrName) ||
Constants.SOAP11_ATTR_ACTOR.equals(xmlAttrName)
- || Constants.SOAP11_ATTR_ROLE.equals(xmlAttrName))
+ || Constants.SOAP12_ATTR_ROLE.equals(xmlAttrName))
{
nsURI = Constants.NS_SOAP11_ENV;
}
Modified: trunk/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java 2006-12-14 15:23:08
UTC (rev 1652)
+++ trunk/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java 2006-12-14 15:56:18
UTC (rev 1653)
@@ -103,6 +103,9 @@
if (domElement == null)
throw new IllegalArgumentException("Source node cannot be null");
+ if (domElement instanceof SOAPElement)
+ return (SOAPElement)domElement;
+
String localName = domElement.getLocalName();
String prefix = domElement.getPrefix() != null ? domElement.getPrefix() :
"";
String nsURI = domElement.getNamespaceURI() != null ? domElement.getNamespaceURI()
: "";
Modified: trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java 2006-12-14
15:23:08 UTC (rev 1652)
+++ trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java 2006-12-14
15:56:18 UTC (rev 1653)
@@ -35,7 +35,6 @@
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
-import org.jboss.util.NotImplementedException;
import org.jboss.ws.Constants;
/**
@@ -48,6 +47,7 @@
*/
public class SOAPHeaderElementImpl extends SOAPContentElement implements
SOAPHeaderElement
{
+
public SOAPHeaderElementImpl(Name name)
{
super(name);
@@ -58,6 +58,34 @@
super(element);
}
+ public String getRole()
+ {
+ String envURI = Constants.NS_SOAP12_ENV;
+ String attr = getAttributeNS(envURI, Constants.SOAP12_ATTR_ROLE);
+ return attr;
+ }
+
+ public void setRole(String roleURI)
+ {
+ String envURI = Constants.NS_SOAP12_ENV;
+ String qualifiedName = Constants.PREFIX_ENV + ":" +
Constants.SOAP12_ATTR_ROLE;
+ setAttributeNS(envURI, qualifiedName, roleURI);
+ }
+
+ public boolean getRelay()
+ {
+ String envURI = Constants.NS_SOAP12_ENV;
+ String attr = getAttributeNS(envURI, Constants.SOAP12_ATTR_RELAY);
+ return "true".equals(attr);
+ }
+
+ 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());
+ }
+
public String getActor()
{
String envURI = Constants.NS_SOAP11_ENV;
@@ -140,22 +168,4 @@
writer.write(xmlFragment);
}
-
- public boolean getRelay()
- {
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
- }
-
- public boolean getRole()
- {
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
- }
-
- public void setRelay(boolean relay) throws SOAPException
- {
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
- }
}