Author: jim.ma
Date: 2009-12-01 02:01:23 -0500 (Tue, 01 Dec 2009)
New Revision: 11174
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2651/
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2651/EnvelopBuilderTestCase.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java
Log:
[JBWS-2651]:set igoreParseError to false
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java 2009-11-30
17:53:43 UTC (rev 11173)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java 2009-12-01
07:01:23 UTC (rev 11174)
@@ -91,8 +91,8 @@
}
public SOAPEnvelope build(SOAPMessage soapMessage, InputStream in, boolean
ignoreParseError) throws IOException, SOAPException
- {
- try
+ {
+ try
{
reader = getFactoryInstance().createXMLStreamReader(in);
}
@@ -285,7 +285,9 @@
{
SOAPBody soapBody = soapEnv.getBody();
-
+ if (soapBody == null) {
+ soapBody = soapEnv.addBody();
+ }
if (atPartMargin())
{
// the env:Body element
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2009-11-30
17:53:43 UTC (rev 11173)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2009-12-01
07:01:23 UTC (rev 11174)
@@ -290,6 +290,15 @@
{
envBuilder =
(EnvelopeBuilder)ServiceLoader.loadService(EnvelopeBuilder.class.getName(), null);
}
+ //if inputstream is empty, no need to build
+ if (inputStream.markSupported()) {
+ inputStream.mark(1);
+ final int bytesRead = inputStream.read(new byte[1]);
+ inputStream.reset();
+ if (bytesRead == -1) {
+ return soapMessage;
+ }
+ }
// Build the payload
envBuilder.setStyle(getStyle());
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2009-11-30
17:53:43 UTC (rev 11173)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2009-12-01
07:01:23 UTC (rev 11174)
@@ -48,7 +48,7 @@
try
{
- SOAPMessage soapMsg = getMessageFactory().createMessage(null, inputStream,
true);
+ SOAPMessage soapMsg = getMessageFactory().createMessage(null, inputStream,
false);
return soapMsg;
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java 2009-11-30
17:53:43 UTC (rev 11173)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java 2009-12-01
07:01:23 UTC (rev 11174)
@@ -79,7 +79,8 @@
if (resCode != HttpServletResponse.SC_NO_CONTENT)
{
MimeHeaders mimeHeaders = getMimeHeaders(metadata);
- soapMsg = getMessageFactory().createMessage(mimeHeaders, inputStream, true);
+ //[JBWS-2651] modify the ignoreParseError to false
+ soapMsg = getMessageFactory().createMessage(mimeHeaders, inputStream,
false);
}
return soapMsg;
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2651/EnvelopBuilderTestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2651/EnvelopBuilderTestCase.java
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2651/EnvelopBuilderTestCase.java 2009-12-01
07:01:23 UTC (rev 11174)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2651;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.soap.SOAPException;
+
+
+import org.jboss.ws.core.CommonSOAPFaultException;
+import org.jboss.ws.core.soap.EnvelopeBuilderDOM;
+import org.jboss.ws.core.soap.EnvelopeBuilderStax;
+import org.jboss.ws.core.soap.MessageFactoryImpl;
+import org.jboss.ws.core.soap.SOAPMessageImpl;
+
+import junit.framework.TestCase;
+
+public class EnvelopBuilderTestCase extends TestCase {
+
+ EnvelopeBuilderDOM domBuilder = new EnvelopeBuilderDOM();
+ EnvelopeBuilderStax staxBuilder = new EnvelopeBuilderStax();
+ MessageFactoryImpl factory = new MessageFactoryImpl();
+
+ public void testEmptyInputStream() throws Exception {
+ InputStream ins = new ByteArrayInputStream("".getBytes());
+ factory.createMessage(null, ins, false);
+ }
+
+ public void testDomInputStream() throws Exception {
+ String soapMsg =
+ "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <env:Header/>" +
+ " <env:Body>" +
+ " <ns1:addItemResponse
xmlns:ns1='http://org.jboss.ws/addressing/replyto'>" +
+ " <result>Mars Bar</result>" +
+ " </ns1:addItemResponse>" +
+ " </env:Body>" +
+ "</env:Envelope>";
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)factory.createMessage();
+ InputStream ins = new ByteArrayInputStream(soapMsg.getBytes());
+ assertNotNull(domBuilder.build(soapMessage, ins, false));
+ }
+
+
+ public void testStaxInputStream() throws Exception {
+ String soapMsg =
+ "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <env:Header/>" +
+ " <env:Body>" +
+ " <ns1:addItemResponse
xmlns:ns1='http://org.jboss.ws/addressing/replyto'>" +
+ " <result>Mars Bar</result>" +
+ " </ns1:addItemResponse>" +
+ " </env:Body>" +
+ "</env:Envelope>";
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)factory.createMessage();
+ InputStream ins = new ByteArrayInputStream(soapMsg.getBytes());
+ assertNotNull(staxBuilder.build(soapMessage, ins, false));
+ }
+
+
+ public void testDomErroStream(){
+ String soapMsg =
+ "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <env:Header/>" +
+ " <env:Body>" +
+ " <ns1:addItemResponse
xmlns:ns1='http://org.jboss.ws/addressing/replyto'>" +
+ " <result>Mars Bar</result>" +
+ " </ns1:addItemResponse>" +
+ " </env:Body>" +
+ "</env:Envelope";
+
+ try {
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)factory.createMessage();
+ InputStream ins = new ByteArrayInputStream(soapMsg.getBytes());
+ domBuilder.build(soapMessage, ins, false);
+ fail("expected SOAPException");
+ } catch (Exception e) {
+ assertTrue(e instanceof CommonSOAPFaultException);
+ }
+ }
+
+
+ public void testStaxErroStream(){
+ String soapMsg =
+ "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <env:Header/>" +
+ " <env:Body>" +
+ " <ns1:addItemResponse
xmlns:ns1='http://org.jboss.ws/addressing/replyto'>" +
+ " <result>Mars Bar</result>" +
+ " </ns1:addItemResponse>" +
+ " </env:Body>" +
+ "</env:Envelope";
+
+ try {
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)factory.createMessage();
+ InputStream ins = new ByteArrayInputStream(soapMsg.getBytes());
+ staxBuilder.build(soapMessage, ins, false);
+ fail("expected IOException");
+ } catch (Exception e) {
+ assertTrue(e instanceof IOException);
+ }
+ }
+
+}