Author: thomas.diesler(a)jboss.com
Date: 2008-03-12 14:34:32 -0400 (Wed, 12 Mar 2008)
New Revision: 5948
Removed:
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/soap/
Modified:
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/FastInfosetEnvelopeBuilder.java
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/config/EndpointProperty.java
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetAPITestCase.java
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetTestCase.java
Log:
More on FastInfoset
Modified:
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
===================================================================
---
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2008-03-12
17:38:20 UTC (rev 5947)
+++
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2008-03-12
18:34:32 UTC (rev 5948)
@@ -54,10 +54,12 @@
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.metadata.config.EndpointProperty;
import org.jboss.ws.metadata.config.CommonConfig;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.extensions.wsrm.transport.RMChannel;
import org.jboss.ws.extensions.wsrm.transport.RMTransportHelper;
import org.jboss.ws.extensions.wsrm.transport.RMMetadata;
+import org.jboss.ws.feature.FastInfosetFeature;
/**
* SOAPConnection implementation.
@@ -306,12 +308,14 @@
// May be overridden through endpoint config
if (msgContext != null)
{
- CommonConfig config = msgContext.getEndpointMetaData().getConfig();
+ EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
+ CommonConfig config = epMetaData.getConfig();
// chunksize settings
String chunkSizeValue =
config.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
int chunkSize = chunkSizeValue != null ? Integer.valueOf(chunkSizeValue) :
-1;
- if (chunkSize > 0)
+ boolean isFastInfoset =
epMetaData.isFeatureEnabled(FastInfosetFeature.class);
+ if (chunkSize > 0 && isFastInfoset == false)
{
clientConfig.put(EndpointProperty.CHUNKED_ENCODING_SIZE, chunkSizeValue);
}
Modified:
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/FastInfosetEnvelopeBuilder.java
===================================================================
---
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/FastInfosetEnvelopeBuilder.java 2008-03-12
17:38:20 UTC (rev 5947)
+++
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/FastInfosetEnvelopeBuilder.java 2008-03-12
18:34:32 UTC (rev 5948)
@@ -59,6 +59,7 @@
DOMDocumentParser parser = new DOMDocumentParser();
Document resDoc = DOMUtils.getDocumentBuilder().newDocument();
parser.parse(resDoc, ins);
+ domEnv = resDoc.getDocumentElement();
}
catch (Exception ex)
{
Modified:
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
===================================================================
---
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2008-03-12
17:38:20 UTC (rev 5947)
+++
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2008-03-12
18:34:32 UTC (rev 5948)
@@ -39,6 +39,7 @@
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service.Mode;
import org.jboss.logging.Logger;
@@ -136,6 +137,11 @@
this.serviceMode = serviceMode;
}
+ public void addFeature(WebServiceFeature feature)
+ {
+ this.features.addFeature(feature);
+ }
+
public void setFeatureResolver(FeatureResolver features)
{
this.features = features;
Modified:
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/config/EndpointProperty.java
===================================================================
---
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/config/EndpointProperty.java 2008-03-12
17:38:20 UTC (rev 5947)
+++
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/config/EndpointProperty.java 2008-03-12
18:34:32 UTC (rev 5948)
@@ -28,6 +28,11 @@
* @version $Id$
* @since 14.12.2006
*/
+
+/**
+ * Refactor this to use features
+ */
+@Deprecated
public class EndpointProperty
{
public final static String MTOM_THRESHOLD =
"http://org.jboss.ws/mtom#threshold";
Modified:
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-03-12
17:38:20 UTC (rev 5947)
+++
stack/native/branches/tdiesler/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-03-12
18:34:32 UTC (rev 5948)
@@ -63,6 +63,7 @@
import org.jboss.ws.core.soap.Use;
import org.jboss.ws.extensions.wsrm.config.RMConfig;
import org.jboss.ws.extensions.wsrm.config.RMPortConfig;
+import org.jboss.ws.feature.FastInfosetFeature;
import org.jboss.ws.metadata.accessor.AccessorFactory;
import org.jboss.ws.metadata.accessor.AccessorFactoryCreator;
import org.jboss.ws.metadata.accessor.JAXBAccessorFactoryCreator;
@@ -368,6 +369,11 @@
return features.getFeature(key);
}
+ public <T extends WebServiceFeature> boolean isFeatureEnabled(Class<T>
key)
+ {
+ return features.isFeatureEnabled(key);
+ }
+
public FeatureResolver getFeatureResolver()
{
return features;
Modified:
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetAPITestCase.java
===================================================================
---
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetAPITestCase.java 2008-03-12
17:38:20 UTC (rev 5947)
+++
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetAPITestCase.java 2008-03-12
18:34:32 UTC (rev 5948)
@@ -23,10 +23,21 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.ws.core.soap.MessageContextAssociation;
+import org.jboss.ws.core.soap.MessageFactoryImpl;
+import org.jboss.ws.feature.FastInfosetFeature;
import org.jboss.wsf.common.DOMUtils;
import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.test.JBossWSTest;
+import org.jvnet.fastinfoset.FastInfosetException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -43,58 +54,67 @@
{
public void testSimple() throws Exception
{
- DOMDocumentSerializer serializer = new DOMDocumentSerializer();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- serializer.setOutputStream(baos);
-
String srcXML = "<root>hello world</root>";
- Element srcRoot = DOMUtils.parse(srcXML);
- serializer.serialize(srcRoot);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- DOMDocumentParser parser = new DOMDocumentParser();
- Document resDoc = DOMUtils.getDocumentBuilder().newDocument();
- parser.parse(resDoc, bais);
-
+ ByteArrayInputStream bais = getFastInputStream(srcXML);
+ Document resDoc = getFastDocument(bais);
String resXML = DOMWriter.printNode(resDoc, false);
assertEquals(srcXML, resXML);
}
public void testSimpleNamespace() throws Exception
{
- DOMDocumentSerializer serializer = new DOMDocumentSerializer();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- serializer.setOutputStream(baos);
-
String srcXML = "<root xmlns='http://somens'>hello
world</root>";
- Element srcRoot = DOMUtils.parse(srcXML);
- serializer.serialize(srcRoot);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- DOMDocumentParser parser = new DOMDocumentParser();
- Document resDoc = DOMUtils.getDocumentBuilder().newDocument();
- parser.parse(resDoc, bais);
-
+ ByteArrayInputStream bais = getFastInputStream(srcXML);
+ Document resDoc = getFastDocument(bais);
String resXML = DOMWriter.printNode(resDoc, false);
assertEquals(srcXML, resXML);
}
public void testPrefixedNamespace() throws Exception
{
+ String srcXML = "<ns1:root xmlns:ns1='http://somens'>hello
world</ns1:root>";
+ ByteArrayInputStream bais = getFastInputStream(srcXML);
+ Document resDoc = getFastDocument(bais);
+ String resXML = DOMWriter.printNode(resDoc, false);
+ assertEquals(srcXML, resXML);
+ }
+
+ public void testMessageFactory() throws Exception
+ {
+ String srcXML =
+ "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <env:Body>" +
+ " <ns1:echo
xmlns:ns1='http://org.jboss.ws/fastinfoset'><arg0>hello
world</arg0></ns1:echo>" +
+ " </env:Body>" +
+ "</env:Envelope>";
+
+ Element srcEnv = DOMUtils.parse(srcXML);
+ ByteArrayInputStream bais = getFastInputStream(srcXML);
+
+ MessageFactoryImpl factory = new MessageFactoryImpl();
+ factory.addFeature(new FastInfosetFeature());
+ SOAPMessage soapMessage = factory.createMessage(null, bais);
+ SOAPEnvelope resEnv = soapMessage.getSOAPPart().getEnvelope();
+ assertEquals(srcEnv, resEnv);
+ }
+
+ private ByteArrayInputStream getFastInputStream(String srcXML) throws IOException
+ {
DOMDocumentSerializer serializer = new DOMDocumentSerializer();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
serializer.setOutputStream(baos);
-
- String srcXML = "<ns1:root xmlns:ns1='http://somens'>hello
world</ns1:root>";
Element srcRoot = DOMUtils.parse(srcXML);
serializer.serialize(srcRoot);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ return bais;
+ }
+
+ private Document getFastDocument(ByteArrayInputStream bais) throws
FastInfosetException, IOException
+ {
DOMDocumentParser parser = new DOMDocumentParser();
Document resDoc = DOMUtils.getDocumentBuilder().newDocument();
parser.parse(resDoc, bais);
-
- String resXML = DOMWriter.printNode(resDoc, false);
- assertEquals(srcXML, resXML);
+ return resDoc;
}
}
Modified:
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetTestCase.java
===================================================================
---
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetTestCase.java 2008-03-12
17:38:20 UTC (rev 5947)
+++
stack/native/branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/fastinfoset/FastInfosetTestCase.java 2008-03-12
18:34:32 UTC (rev 5948)
@@ -21,7 +21,11 @@
*/
package org.jboss.test.ws.jaxws.fastinfoset;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
import java.net.URL;
+import java.net.URLConnection;
import javax.xml.namespace.QName;
import javax.xml.ws.Service21;
@@ -29,9 +33,13 @@
import junit.framework.Test;
import org.jboss.ws.feature.FastInfosetFeature;
+import org.jboss.wsf.common.DOMUtils;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Element;
+import com.sun.xml.fastinfoset.dom.DOMDocumentSerializer;
+
/**
* Test FastInfoset functionality
*
@@ -45,15 +53,44 @@
return new JBossWSTestSetup(FastInfosetTestCase.class,
"jaxws-fastinfoset.war");
}
- public void testSimple() throws Exception
+ public void testURLConnection() throws Exception
{
+ String reqEnv =
+ "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <env:Body>" +
+ " <ns1:echo
xmlns:ns1='http://org.jboss.ws/fastinfoset'><arg0>hello
world</arg0></ns1:echo>" +
+ " </env:Body>" +
+ "</env:Envelope>";
+
+ String targetAddress = "http://" + getServerHost() +
":8080/jaxws-fastinfoset";
+ HttpURLConnection con = (HttpURLConnection)new
URL(targetAddress).openConnection();
+ con.setRequestProperty("Content-Type", "text/xml;
charset=UTF-8");
+ con.setRequestMethod("POST");
+ con.setDoOutput(true);
+ con.connect();
+
+ OutputStream outs = con.getOutputStream();
+ DOMDocumentSerializer serializer = new DOMDocumentSerializer();
+ serializer.setOutputStream(outs);
+
+ Element srcRoot = DOMUtils.parse(reqEnv);
+ serializer.serialize(srcRoot);
+ outs.close();
+
+ int resCode = con.getResponseCode();
+ assertEquals(200, resCode);
+ }
+
+ public void _testSimple() throws Exception
+ {
URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-fastinfoset?wsdl");
QName serviceName = new QName("http://org.jboss.ws/fastinfoset",
"FastInfosetEndpointService");
Service21 service = Service21.create(wsdlURL, serviceName);
- FastInfosetFeature feature = new FastInfosetFeature();
+ FastInfosetFeature feature = new FastInfosetFeature(false);
FastInfoset port = service.getPort(FastInfoset.class, feature);
String retStr = port.echo("hello world");
assertEquals("hello world", retStr);
}
+
}