You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2006/12/06 22:49:58 UTC
svn commit: r483250 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/client/ src/org/apache/axis2/jaxws/i18n/
src/org/apache/axis2/jaxws/message/impl/ test/org/apache/axis2/jaxws/message/
Author: scheu
Date: Wed Dec 6 13:49:57 2006
New Revision: 483250
URL: http://svn.apache.org/viewvc?view=rev&rev=483250
Log:
AXIS2-1838
Contributor:Rich Scheuerle
Support for JAX-WS Dispatch<String> Payload mode where the String is empty or is not an element
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java?view=diff&rev=483250&r1=483249&r2=483250
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java Wed Dec 6 13:49:57 2006
@@ -21,6 +21,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Binding;
import javax.xml.ws.Response;
@@ -365,6 +366,13 @@
// if the parameter is null.
if (object == null) {
throw ExceptionFactory.makeWebServiceException("dispatchNullParamHttpBinding");
+ }
+ }
+
+ if (object instanceof DOMSource) {
+ DOMSource ds = (DOMSource) object;
+ if (ds.getNode() == null && ds.getSystemId() == null) {
+ throw ExceptionFactory.makeWebServiceException("");
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties?view=diff&rev=483250&r1=483249&r2=483250
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties Wed Dec 6 13:49:57 2006
@@ -137,4 +137,5 @@
JABGraphProblem=The system threw a StackOverflowError at the JAXB level. This usually means that your JAXB object has a circular reference. This is not supported by JAXB.
SchemaReaderErr1=Invlid wsdl Definition provided.
SchemaReaderErr2=Circular Dependency Found in WSDL Schema Imports, Two Schemas are importing each other.
-XSDListNotSupported=An attempt was made to marshal or unmarshal an xsd:list with a component type that is a {0}. This scenario is not supported for rpc/literal processing. Please use document/literal processing.
\ No newline at end of file
+XSDListNotSupported=An attempt was made to marshal or unmarshal an xsd:list with a component type that is a {0}. This scenario is not supported for rpc/literal processing. Please use document/literal processing
+dispatchBadDOMSource=An invalid DOMSource was encountered during Dispatch. Please use a DOMSource that contains a Node.
\ No newline at end of file
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java?view=diff&rev=483250&r1=483249&r2=483250
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java Wed Dec 6 13:49:57 2006
@@ -166,7 +166,8 @@
qName = omElement.getQName();
}
return qName;
- } catch (XMLStreamException xse) {
+ } catch (Exception xse) {
+ setConsumed(true);
throw ExceptionFactory.makeMessageException(xse);
}
}
@@ -279,7 +280,7 @@
* @param consume
* @return
*/
- private void setConsumed(boolean consume) {
+ public void setConsumed(boolean consume) {
if (consume) {
this.consumed = true;
busObject = null;
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java?view=diff&rev=483250&r1=483249&r2=483250
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java Wed Dec 6 13:49:57 2006
@@ -53,6 +53,8 @@
import org.apache.axis2.jaxws.message.util.Reader2Writer;
import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* XMLSpineImpl
@@ -68,6 +70,7 @@
*/
class XMLSpineImpl implements XMLSpine {
+ private static Log log = LogFactory.getLog(XMLSpine.class);
private static OMBlockFactory obf = (OMBlockFactory) FactoryRegistry.getFactory(OMBlockFactory.class);
private Protocol protocol = Protocol.unknown;
@@ -340,17 +343,33 @@
}
if (bodyBlocks != null) {
for (int i=0; i<bodyBlocks.size(); i++) {
- Block b = (Block) bodyBlocks.get(i);
- OMElement e = new OMSourcedElementImpl(b.getQName(),soapFactory, b);
+ Block b = (Block) bodyBlocks.get(i);
- // The blocks are directly under the body if DOCUMENT.
- // The blocks are under the operation element if RPC
- if (style == Style.DOCUMENT) {
- root.getBody().addChild(e);
- } else {
- root.getBody().getFirstElement().addChild(e);
+ // In Dispatch<String> Provider<String> and some source modes, the block is built from text data.
+ // The assumption is that the text data represents one or more elements, but this may not be the
+ // case. It could represent whitespace. In such cases querying the qname will cause a parse of the
+ // code and the parse will fail. We will interpret a failure as an indication that the block does not represent
+ // an element
+
+ QName blockQName = null;
+ try {
+ blockQName = b.getQName();
+ } catch (Exception e) {
+ log.debug("The block does not represent an element");
}
-
+
+ // Only create an OMElement if the block represents an element
+ if (blockQName != null) {
+ OMElement e = new OMSourcedElementImpl(b.getQName(),soapFactory, b);
+
+ // The blocks are directly under the body if DOCUMENT.
+ // The blocks are under the operation element if RPC
+ if (style == Style.DOCUMENT) {
+ root.getBody().addChild(e);
+ } else {
+ root.getBody().getFirstElement().addChild(e);
+ }
+ }
}
bodyBlocks.clear();
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java?view=diff&rev=483250&r1=483249&r2=483250
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java Wed Dec 6 13:49:57 2006
@@ -70,6 +70,16 @@
"<b>Hello</b>" +
"<c>World</c>" +
"</pre:a>";
+
+ private static final String sampleDouble =
+ "<pre:a xmlns:pre=\"urn://sample\">" +
+ "<b>Hello</b>" +
+ "<c>World</c>" +
+ "</pre:a>" +
+ "<pre:aa xmlns:pre=\"urn://sample\">" +
+ "<b>Hello</b>" +
+ "<c>World</c>" +
+ "</pre:aa>";
private static final String sampleEnvelope11 =
sampleEnvelopeHead11 +
@@ -247,7 +257,132 @@
assertTrue(newText.contains("Body"));
}
+
+ /**
+ * Create a Block representing an empty XMLString and simulate a
+ * normal Dispatch<String> flow with an application handler.
+ * @throws Exception
+ */
+ public void testStringOutflowEmptyString() throws Exception {
+
+ // Create a SOAP 1.1 Message
+ MessageFactory mf = (MessageFactory)
+ FactoryRegistry.getFactory(MessageFactory.class);
+ Message m = mf.create(Protocol.soap11);
+
+ // Get the BlockFactory
+ XMLStringBlockFactory f = (XMLStringBlockFactory)
+ FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+
+ // Sample text is whitespace. There is no element
+
+ String whiteSpaceText = "<!-- Comment -->";
+ // Create a Block using the sample string as the content. This simulates
+ // what occurs on the outbound JAX-WS dispatch<String> client
+ Block block = f.createFrom(whiteSpaceText, null, null);
+
+ // Add the block to the message as normal body content.
+ m.setBodyBlock(0, block);
+
+ // If there is a JAX-WS handler, the Message is converted into a SOAPEnvelope
+ SOAPEnvelope soapEnvelope = m.getAsSOAPEnvelope();
+
+ // Check to see if the message is a fault. The client/server will always call this method.
+ // The Message must respond appropriately without doing a conversion.
+ boolean isFault = m.isFault();
+ assertTrue(!isFault);
+ assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+ "SOAPENVELOPE".equals(m.getXMLPartContentType()));
+
+ // Normally the handler would not touch the body...but for our scenario, assume that it does.
+ // The whitespace is not preserved, so there should be no first child in the body
+ assertTrue(soapEnvelope.getBody().getFirstChild() == null);
+
+ // The block should be consumed at this point
+ assertTrue(block.isConsumed());
+
+ // After the handler processing the message is obtained as an OM
+ OMElement om = m.getAsOMElement();
+
+ // Serialize the Envelope using the same mechanism as the
+ // HTTP client.
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ om.serializeAndConsume(baos, new OMOutputFormat());
+
+ // To check that the output is correct, get the String contents of the
+ // reader
+ String newText = baos.toString();
+ System.out.println(newText);
+ assertTrue(newText.contains("soap"));
+ assertTrue(newText.contains("Envelope"));
+ assertTrue(newText.contains("Body"));
+
+ }
+ /**
+ * Create a Block representing an XMLString with 2 elements and simulate a
+ * normal Dispatch<String> flow with an application handler.
+ * @throws Exception
+ *
+ * @REVIEW This test is disabled because (a) it fails and (b) we don't believe this
+ * is allowed due by WSI.
+ */
+ public void _testStringOutflowDoubleElement() throws Exception {
+
+ // Create a SOAP 1.1 Message
+ MessageFactory mf = (MessageFactory)
+ FactoryRegistry.getFactory(MessageFactory.class);
+ Message m = mf.create(Protocol.soap11);
+
+ // Get the BlockFactory
+ XMLStringBlockFactory f = (XMLStringBlockFactory)
+ FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+
+ // Create a Block using the sample string as the content. This simulates
+ // what occurs on the outbound JAX-WS dispatch<String> client
+ // In this case the sample string contains 2 elements a and aa
+ Block block = f.createFrom(this.sampleDouble, null, null);
+
+ // Add the block to the message as normal body content.
+ m.setBodyBlock(0, block);
+
+ // If there is a JAX-WS handler, the Message is converted into a SOAPEnvelope
+ SOAPEnvelope soapEnvelope = m.getAsSOAPEnvelope();
+
+ // Check to see if the message is a fault. The client/server will always call this method.
+ // The Message must respond appropriately without doing a conversion.
+ boolean isFault = m.isFault();
+ assertTrue(!isFault);
+ assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+ "SOAPENVELOPE".equals(m.getXMLPartContentType()));
+
+ // Normally the handler would not touch the body...but for our scenario, assume that it does.
+ String name = soapEnvelope.getBody().getFirstChild().getLocalName();
+ assertTrue("a".equals(name));
+ name = soapEnvelope.getBody().getLastChild().getLocalName();
+ assertTrue("aa".equals(name));
+
+ // The block should be consumed at this point
+ assertTrue(block.isConsumed());
+
+ // After the handler processing the message is obtained as an OM
+ OMElement om = m.getAsOMElement();
+
+ // Serialize the Envelope using the same mechanism as the
+ // HTTP client.
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ om.serializeAndConsume(baos, new OMOutputFormat());
+
+ // To check that the output is correct, get the String contents of the
+ // reader
+ String newText = baos.toString();
+ System.out.println(newText);
+ assertTrue(newText.contains(sampleText));
+ assertTrue(newText.contains("soap"));
+ assertTrue(newText.contains("Envelope"));
+ assertTrue(newText.contains("Body"));
+
+ }
/**
* Create a Block representing an XMLString and simulate a
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org