Author: darran.lofthouse(a)jboss.com
Date: 2007-07-24 18:05:26 -0400 (Tue, 24 Jul 2007)
New Revision: 3982
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/javax/xml/soap/SOAPEnvelope.java
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilder.java
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderPayload.java
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPEnvelopeImpl.java
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPPartImpl.java
Log:
Roll back first prototype.
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/javax/xml/soap/SOAPEnvelope.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/javax/xml/soap/SOAPEnvelope.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/javax/xml/soap/SOAPEnvelope.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -21,55 +21,29 @@
*/
package javax.xml.soap;
-/** The container for the SOAPHeader and SOAPBody portions of a SOAPPart object.
- * By default, a SOAPMessage object is created with a SOAPPart object that has a
SOAPEnvelope object.
- * The SOAPEnvelope object by default has an empty SOAPBody object and an empty
SOAPHeader object.<p>
- * The SOAPBody object is required, and the SOAPHeader object, though optional,
- * is used in the majority of cases. If the SOAPHeader object is not needed, it can be
deleted, which is shown later.<p>
- * A client can access the SOAPHeader and SOAPBody objects by calling the methods
SOAPEnvelope.getHeader and SOAPEnvelope.getBody.
- * The following lines of code use these two methods after starting with the SOAPMessage
object message to get the SOAPPart object
- * sp, which is then used to get the SOAPEnvelope object se.<p>
- *
- * <code>
- * SOAPPart sp = message.getSOAPPart();<br>
- * SOAPEnvelope se = sp.getEnvelope();<br>
- * SOAPHeader sh = se.getHeader();<br>
- * SOAPBody sb = se.getBody(); <br>
- * </code>
- * <p>
- * It is possible to change the body or header of a SOAPEnvelope object by retrieving the
current one,
- * deleting it, and then adding a new body or header.
- * The javax.xml.soap.Node method deleteNode deletes the XML element (node) on which it
is called.
- * For example, the following line of code deletes the SOAPBody object that is retrieved
by the method getBody.
- * <p>
- * <code>se.getBody().detachNode();</code>
- * <p>
- * To create a SOAPHeader object to replace the one that was removed,
- * a client uses the method SOAPEnvelope.addHeader, which creates a new header and adds
it to the SOAPEnvelope object.
- * Similarly, the method addBody creates a new SOAPBody object and adds it to the
SOAPEnvelope object.
- * The following code fragment retrieves the current header, removes it, and adds a new
one.
- * Then it retrieves the current body, removes it, and adds a new one.
- * <p>
- * <code>
- * SOAPPart sp = message.getSOAPPart();<br>
- * SOAPEnvelope se = sp.getEnvelope();<br>
- * se.getHeader().detachNode(); <br>
- * SOAPHeader sh = se.addHeader();<br>
- * se.getBody().detachNode(); <br>
- * SOAPBody sb = se.addBody();<br>
- * </code>
- * <p>
- * <b>It is an error to add a SOAPBody or SOAPHeader object if one already
exists.</b>
- * The SOAPEnvelope interface provides three methods for creating Name objects.
- * One method creates Name objects with a local name, a namespace prefix, and a namesapce
URI.
- * The second method creates Name objects with a local name and a namespace prefix,
- * and the third creates Name objects with just a local name.
- * <p>
- * The following line of code, in which se is a SOAPEnvelope object, creates a new Name
object with all three.
- * <code>
- * Name name = se.createName("GetLastTradePrice", "WOMBAT",
"http://www.wombat.org/trader");
- * </code>
- *
+/** The container for the SOAPHeader and SOAPBody portions of a SOAPPart object. By
default, a SOAPMessage object is created with a SOAPPart object that has a SOAPEnvelope
object. The SOAPEnvelope object by default has an empty SOAPBody object and an empty
SOAPHeader object. The SOAPBody object is required, and the SOAPHeader object, though
optional, is used in the majority of cases. If the SOAPHeader object is not needed, it can
be deleted, which is shown later.
+ A client can access the SOAPHeader and SOAPBody objects by calling the methods
SOAPEnvelope.getHeader and SOAPEnvelope.getBody. The following lines of code use these two
methods after starting with the SOAPMessage object message to get the SOAPPart object sp,
which is then used to get the SOAPEnvelope object se.
+ SOAPPart sp = message.getSOAPPart();
+ SOAPEnvelope se = sp.getEnvelope();
+ SOAPHeader sh = se.getHeader();
+ SOAPBody sb = se.getBody();
+
+ It is possible to change the body or header of a SOAPEnvelope object by retrieving the
current one, deleting it, and then adding a new body or header. The javax.xml.soap.Node
method deleteNode deletes the XML element (node) on which it is called. For example, the
following line of code deletes the SOAPBody object that is retrieved by the method
getBody.
+ se.getBody().detachNode();
+
+ To create a SOAPHeader object to replace the one that was removed, a client uses the
method SOAPEnvelope.addHeader, which creates a new header and adds it to the SOAPEnvelope
object. Similarly, the method addBody creates a new SOAPBody object and adds it to the
SOAPEnvelope object. The following code fragment retrieves the current header, removes it,
and adds a new one. Then it retrieves the current body, removes it, and adds a new one.
+ SOAPPart sp = message.getSOAPPart();
+ SOAPEnvelope se = sp.getEnvelope();
+ se.getHeader().detachNode();
+ SOAPHeader sh = se.addHeader();
+ se.getBody().detachNode();
+ SOAPBody sb = se.addBody();
+
+ It is an error to add a SOAPBody or SOAPHeader object if one already exists.
+ The SOAPEnvelope interface provides three methods for creating Name objects. One method
creates Name objects with a local name, a namespace prefix, and a namesapce URI. The
second method creates Name objects with a local name and a namespace prefix, and the third
creates Name objects with just a local name. The following line of code, in which se is a
SOAPEnvelope object, creates a new Name object with all three.
+ Name name = se.createName("GetLastTradePrice", "WOMBAT",
+ "http://www.wombat.org/trader");
+
* @author Scott.Stark(a)jboss.org
* @version $Revision$
*/
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilder.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilder.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilder.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -24,13 +24,12 @@
// $Id$
import java.io.IOException;
+import java.io.InputStream;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
-import org.xml.sax.InputSource;
-
/**
* @author Heiko Braun, <heiko.braun(a)jboss.com>
* @author Thomas.Diesler(a)jboss.com
@@ -38,5 +37,5 @@
*/
public interface EnvelopeBuilder
{
- SOAPEnvelope build(SOAPMessage soapMessage, InputSource is, boolean ignoreParseError)
throws IOException, SOAPException;
+ SOAPEnvelope build(SOAPMessage soapMessage, InputStream in, boolean ignoreParseError)
throws IOException, SOAPException;
}
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -23,28 +23,20 @@
//$Id$
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.Detail;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.transform.dom.DOMSource;
-
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.jaxrpc.Style;
import org.jboss.ws.core.utils.DOMUtils;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
+import javax.xml.namespace.QName;
+import javax.xml.soap.*;
+import javax.xml.transform.dom.DOMSource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+
/**
* A SOAPEnvelope builder for JAXRPC based on DOM
*
@@ -64,13 +56,13 @@
this.style = style;
}
- public SOAPEnvelope build(SOAPMessage soapMessage, InputSource is, boolean
ignoreParseError) throws IOException, SOAPException
+ public SOAPEnvelope build(SOAPMessage soapMessage, InputStream ins, boolean
ignoreParseError) throws IOException, SOAPException
{
// Parse the XML input stream
Element domEnv = null;
try
{
- domEnv = DOMUtils.parse(is);
+ domEnv = DOMUtils.parse(ins);
}
catch (IOException ex)
{
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderPayload.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderPayload.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderPayload.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -24,6 +24,7 @@
//$Id$
import java.io.IOException;
+import java.io.InputStream;
import java.util.Iterator;
import javax.xml.namespace.QName;
@@ -35,8 +36,8 @@
import javax.xml.transform.dom.DOMSource;
import org.jboss.ws.core.utils.DOMUtils;
+import org.jboss.ws.core.utils.DOMWriter;
import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
/**
* A SOAPEnvelope builder for JAXWS in service mode PAYLOAD
@@ -46,13 +47,13 @@
*/
public class EnvelopeBuilderPayload implements EnvelopeBuilder
{
- public SOAPEnvelope build(SOAPMessage soapMessage, InputSource is, boolean
ignoreParseError) throws IOException, SOAPException
+ public SOAPEnvelope build(SOAPMessage soapMessage, InputStream ins, boolean
ignoreParseError) throws IOException, SOAPException
{
// Parse the XML input stream
Element domEnv = null;
try
{
- domEnv = DOMUtils.parse(is);
+ domEnv = DOMUtils.parse(ins);
}
catch (IOException ex)
{
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderStax.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -41,7 +41,6 @@
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
import com.ctc.wstx.stax.WstxInputFactory;
@@ -92,20 +91,11 @@
this.fragmentBuffer.ensureCapacity(2048);
}
- public SOAPEnvelope build(SOAPMessage soapMessage, InputSource is, boolean
ignoreParseError) throws IOException, SOAPException
+ public SOAPEnvelope build(SOAPMessage soapMessage, InputStream in, boolean
ignoreParseError) throws IOException, SOAPException
{
try
{
- XMLInputFactory factory = getFactoryInstance();
- InputStream ins = is.getByteStream();
- if (ins != null)
- {
- reader = factory.createXMLStreamReader(ins);
- }
- else
- {
- reader = factory.createXMLStreamReader(is.getCharacterStream());
- }
+ reader = getFactoryInstance().createXMLStreamReader(in);
}
catch (XMLStreamException e)
{
@@ -247,8 +237,7 @@
}
// TODO: this is rubbish. Use Source internally instead...
- private XMLFragment bufferToFragment(StringBuffer fragmentBuffer)
- {
+ private XMLFragment bufferToFragment(StringBuffer fragmentBuffer) {
StreamSource source = new StreamSource(new
ByteArrayInputStream(fragmentBuffer.toString().getBytes()));
return new XMLFragment(source);
}
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -27,8 +27,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.util.Collection;
import java.util.Iterator;
@@ -49,7 +47,6 @@
import org.jboss.ws.core.soap.attachment.MimeConstants;
import org.jboss.ws.core.soap.attachment.MultipartRelatedDecoder;
import org.jboss.ws.core.utils.IOUtils;
-import org.xml.sax.InputSource;
/**
* MessageFactory implementation
@@ -77,7 +74,8 @@
{
if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol))
envNamespace = SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;
- else envNamespace = SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE;
+ else
+ envNamespace = SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE;
}
/**
@@ -190,8 +188,7 @@
}
ContentType contentType = getContentType(mimeHeaders);
- if (log.isDebugEnabled())
- log.debug("createMessage: [contentType=" + contentType +
"]");
+ if(log.isDebugEnabled()) log.debug("createMessage: [contentType=" +
contentType + "]");
// Debug the incoming message
if (log.isTraceEnabled())
@@ -252,21 +249,8 @@
envBuilder = new EnvelopeBuilderDOM(getStyle());
}
- String charset = contentType.getParameter("charset");
- Reader reader = null;
-
- if (charset != null)
- {
- reader = new InputStreamReader(ins, charset);
- }
- else
- {
- reader = new InputStreamReader(ins);
- }
- InputSource source = new InputSource(reader);
-
// Build the payload
- envBuilder.build(soapMessage, source, ignoreParseError);
+ envBuilder.build(soapMessage, ins, ignoreParseError);
return soapMessage;
}
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPEnvelopeImpl.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPEnvelopeImpl.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPEnvelopeImpl.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -71,9 +71,8 @@
assertEnvelopeNamespace(namespaceURI);
addNamespaceDeclaration(prefix, namespaceURI);
- // the Element source might already contain a Header and Body declaration
- if(null == soapPart.getEnvelope().getHeader()) addHeader();
- if(null == soapPart.getEnvelope().getBody()) addBody();
+ addHeader();
+ addBody();
}
/** Construct a SOAP envelope for the given SOAP version URI.
Modified:
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPPartImpl.java
===================================================================
---
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPPartImpl.java 2007-07-24
21:58:32 UTC (rev 3981)
+++
branches/dlofthouse/JBWS-1763/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPPartImpl.java 2007-07-24
22:05:26 UTC (rev 3982)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.
- */
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ws.core.soap;
// $Id$
@@ -28,7 +28,12 @@
import java.util.Iterator;
import java.util.List;
-import javax.xml.soap.*;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
@@ -53,7 +58,6 @@
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
import org.w3c.dom.UserDataHandler;
-import org.xml.sax.InputSource;
/** An implementation of SOAPPart.
*
@@ -79,7 +83,7 @@
{
return soapMessage;
}
-
+
public SOAPEnvelope getEnvelope() throws SOAPException
{
return soapEnvelope;
@@ -144,17 +148,11 @@
// Specifically, the HTTP response entity-body must be empty.
if (source == null)
{
- if (log.isDebugEnabled())
- log.debug("Setting content source to null removes the
SOAPEnvelope");
+ if(log.isDebugEnabled()) log.debug("Setting content source to null removes
the SOAPEnvelope");
soapEnvelope = null;
return;
}
- // Start with a fresh soapMessage
- /*MessageFactory mf = MessageFactory.newInstance();
- soapMessage = mf.createMessage();
- soapMessage.getSOAPHeader().detachNode();*/
-
if (source instanceof DOMSource)
{
Element domElement;
@@ -164,8 +162,9 @@
domElement = ((Document)node).getDocumentElement();
else if (node instanceof Element)
domElement = (Element)node;
- else throw new SOAPException("Unsupported DOMSource node: " + node);
-
+ else
+ throw new SOAPException("Unsupported DOMSource node: " + node);
+
EnvelopeBuilderDOM envBuilder = new EnvelopeBuilderDOM(Style.DOCUMENT);
envBuilder.build(soapMessage, domElement);
}
@@ -175,7 +174,7 @@
{
StreamSource streamSource = (StreamSource)source;
EnvelopeBuilderDOM envBuilder = new EnvelopeBuilderDOM(Style.DOCUMENT);
- envBuilder.build(soapMessage, new InputSource(streamSource.getInputStream()),
false);
+ envBuilder.build(soapMessage, streamSource.getInputStream(), false);
}
catch (IOException e)
{
@@ -303,7 +302,7 @@
if (soapEnvelope != null)
{
list.add((NodeImpl)soapEnvelope);
- }
+ }
return new NodeListImpl(list);
}