You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2010/12/17 15:41:22 UTC
Re: svn commit: r1050284 - in /cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/interceptor/ rt/transports/common/src/main/java/org/apache/cxf/transport/common/gzip/ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ rt/...
Freeman,
> + public static final String SOAP_JMS_CONTENTENCODING =
> "SOAPJMS_contentEncoding";
I'm a bit concerned about pushing SOAP/JMS things out beyone the SOAP binding.
Is it possible to have the SOAP/JMS interceptors or similar just map this
directly into the normal CONTENT_ENCODING header the GZIP interceptors already
use? I think we already do that for a few headers, right?
Dan
On Friday 17 December 2010 1:37:59 am ffang@apache.org wrote:
> Author: ffang
> Date: Fri Dec 17 06:37:59 2010
> New Revision: 1050284
>
> URL: http://svn.apache.org/viewvc?rev=1050284&view=rev
> Log:
> [CXF-3174]support gzip encoding compliant with Soap over JMS spec
>
> Added:
>
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Gzi
> pServer.java
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMS
> ClientServerGzipTest.java
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzi
> pBus.xml Modified:
>
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/JMSFaultFactory.java
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSConstants.java
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSInInterceptor.java
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPFeature.java
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPInInterceptor.java
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPOutInterceptor.java
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMS
> Utils.java
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spe
> c/JMSSpecConstants.java
> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
>
> Modified:
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/JMSFaultFactory.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/
> apache/cxf/binding/soap/jms/interceptor/JMSFaultFactory.java?rev=1050284&r1
> =1050283&r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/JMSFaultFactory.java (original) +++
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/JMSFaultFactory.java Fri Dec 17 06:37:59 2010 @@ -43,6 +43,14 @@
> public final class JMSFaultFactory {
> return createFault(SoapJMSConstants.getContentTypeMismatchQName(),
> m); }
>
> + public static JMSFault createContentEncodingNotSupported(String
> contentEncoding) { + String m = new
> org.apache.cxf.common.i18n.Message("CONTENT_ENCODING_NOT_SUPPORTED", LOG,
> + new Object[] {
> +
> contentEncoding +
> }).toString(); + return
> createFault(SoapJMSConstants.getContentTypeMismatchQName(), m); + }
> +
> public static JMSFault createMalformedRequestURIFault(String
> requestURI) { String m = new
> org.apache.cxf.common.i18n.Message("MALFORMED_REQUESTURI", LOG, new
> Object[] {
>
> Modified:
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSConstants.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/
> apache/cxf/binding/soap/jms/interceptor/SoapJMSConstants.java?rev=1050284&r
> 1=1050283&r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSConstants.java (original) +++
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSConstants.java Fri Dec 17 06:37:59 2010 @@ -37,6 +37,7 @@
> public final class SoapJMSConstants {
> public static final String SOAPACTION_PARAMETER_NAME = "soapAction";
> public static final String TARGETSERVICE_PARAMETER_NAME =
> "targetService"; public static final String CONTENTTYPE_PARAMETER_NAME =
> "contentType"; + public static final String
> CONTENTENCODING_PARAMETER_NAME = "contentEncoding"; public static final
> String ISFAULT_PARAMETER_NAME = "isFault";
>
> // JMS Field name
> @@ -46,6 +47,7 @@ public final class SoapJMSConstants {
> public static final String SOAPACTION_FIELD = SOAP_JMS_PREFIX +
> SOAPACTION_PARAMETER_NAME; public static final String TARGETSERVICE_FIELD
> = SOAP_JMS_PREFIX + TARGETSERVICE_PARAMETER_NAME; public static final
> String CONTENTTYPE_FIELD = SOAP_JMS_PREFIX + CONTENTTYPE_PARAMETER_NAME; +
> public static final String CONTENTENCODING_FIELD = SOAP_JMS_PREFIX +
> CONTENTENCODING_PARAMETER_NAME; public static final String ISFAULT_FIELD =
> SOAP_JMS_PREFIX + ISFAULT_PARAMETER_NAME;
>
> public static final String SOAP_JMS_SPECIFICIATION_TRANSPORTID =
> "http://www.w3.org/2010/soapjms/"; @@ -53,6 +55,7 @@ public final class
> SoapJMSConstants {
>
> // fault codes
> private static final String JMS_CONTENTTYPEMISMATCH_FAULT_CODE =
> "contentTypeMismatch"; + private static final String
> JMS_CONTENTENCODINGNOTSUPPORTED_FAULT_CODE =
> "contentEncodingNotSupported"; private static final String
> JMS_MALFORMEDREQUESTURI_FAULT_CODE = "malformedRequestURI"; private static
> final String JMS_MISMATCHEDSOAPACTION_FAULT_CODE = "mismatchedSoapAction";
> private static final String JMS_MISSINGCONTENTTYPE_FAULT_CODE =
> "missingContentType"; @@ -68,6 +71,10 @@ public final class
> SoapJMSConstants {
> public static QName getContentTypeMismatchQName() {
> return new QName(SOAP_JMS_NAMESPACE,
> JMS_CONTENTTYPEMISMATCH_FAULT_CODE); }
> +
> + public static QName getContentEncodingNotSupportedQName() {
> + return new QName(SOAP_JMS_NAMESPACE,
> JMS_CONTENTENCODINGNOTSUPPORTED_FAULT_CODE); + }
>
> public static QName getMalformedRequestURIQName() {
> return new QName(SOAP_JMS_NAMESPACE,
> JMS_MALFORMEDREQUESTURI_FAULT_CODE);
>
> Modified:
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSInInterceptor.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/
> apache/cxf/binding/soap/jms/interceptor/SoapJMSInInterceptor.java?rev=10502
> 84&r1=1050283&r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSInInterceptor.java (original) +++
> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/i
> nterceptor/SoapJMSInInterceptor.java Fri Dec 17 06:37:59 2010 @@ -47,6
> +47,7 @@ public class SoapJMSInInterceptor extend
> .get(Message.PROTOCOL_HEADERS));
> if (headers != null) {
> checkContentType(message, headers);
> + checkContentEncoding(message, headers);
> checkRequestURI(message, headers);
> checkSoapAction(message, headers);
> checkBindingVersion(message, headers);
> @@ -58,6 +59,28 @@ public class SoapJMSInInterceptor extend
> * @param message
> * @param headers
> */
> + private void checkContentEncoding(SoapMessage message, Map<String,
> List<String>> headers) { + List<String> contentEncodingList =
> headers.get(SoapJMSConstants.CONTENTENCODING_FIELD); + JMSFault
> jmsFault = null;
> + if (contentEncodingList != null && contentEncodingList.size() > 0)
> { + String contentEncoding = contentEncodingList.get(0);
> + if (!"gzip".equals(contentEncoding)) {
> + jmsFault =
> JMSFaultFactory.createContentEncodingNotSupported(contentEncoding); +
> }
> + }
> + if (jmsFault != null) {
> + Fault f = createFault(message, jmsFault);
> + if (f != null) {
> + throw f;
> + }
> + }
> + }
> +
> +
> + /**
> + * @param message
> + * @param headers
> + */
> private void checkJMSMessageFormat(SoapMessage message, Map<String,
> List<String>> headers) { List<String> mt =
> headers.get(SoapJMSConstants.JMS_MESSAGE_TYPE); if (mt != null &&
> mt.size() > 0) {
>
> Modified:
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPFeature.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/common/src/main/java/
> org/apache/cxf/transport/common/gzip/GZIPFeature.java?rev=1050284&r1=105028
> 3&r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPFeature.java (original) +++
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPFeature.java Fri Dec 17 06:37:59 2010 @@ -68,7 +68,6 @@ public
> class GZIPFeature extends Abstrac
> @Override
> protected void initializeProvider(InterceptorProvider provider, Bus
> bus) { provider.getInInterceptors().add(IN);
> - provider.getInFaultInterceptors().add(IN);
> if (threshold == -1) {
> provider.getOutInterceptors().add(OUT);
> provider.getOutFaultInterceptors().add(OUT);
>
> Modified:
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPInInterceptor.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/common/src/main/java/
> org/apache/cxf/transport/common/gzip/GZIPInInterceptor.java?rev=1050284&r1=
> 1050283&r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPInInterceptor.java (original) +++
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPInInterceptor.java Fri Dec 17 06:37:59 2010 @@ -68,6 +68,9 @@
> public class GZIPInInterceptor extends A
> if (protocolHeaders != null) {
> List<String> contentEncoding =
> HttpHeaderHelper.getHeader(protocolHeaders,
> HttpHeaderHelper.CONTENT_ENCODING); + if (contentEncoding ==
> null) {
> + contentEncoding =
> protocolHeaders.get(GZIPOutInterceptor.SOAP_JMS_CONTENTENCODING); +
> }
> if (contentEncoding != null
> && (contentEncoding.contains("gzip") ||
> contentEncoding.contains("x-gzip"))) { try {
>
> Modified:
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPOutInterceptor.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/common/src/main/java/
> org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java?rev=1050284&r1
> =1050283&r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPOutInterceptor.java (original) +++
> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/transport/comm
> on/gzip/GZIPOutInterceptor.java Fri Dec 17 06:37:59 2010 @@ -89,6 +89,8 @@
> public class GZIPOutInterceptor extends
> * given by the client in Accept-Encoding.
> */
> public static final String GZIP_ENCODING_KEY =
> GZIPOutInterceptor.class.getName() + ".gzipEncoding"; +
> + public static final String SOAP_JMS_CONTENTENCODING =
> "SOAPJMS_contentEncoding";
>
> private static final ResourceBundle BUNDLE =
> BundleUtils.getBundle(GZIPOutInterceptor.class); private static final
> Logger LOG = LogUtils.getL7dLogger(GZIPOutInterceptor.class); @@ -165,6
> +167,11 @@ public class GZIPOutInterceptor extends
> if (requestHeaders != null) {
> List<String> acceptEncodingHeader =
> CastUtils.cast(HttpHeaderHelper .getHeader(requestHeaders,
> HttpHeaderHelper.ACCEPT_ENCODING)); + List<String>
> jmsEncodingHeader =
> CastUtils.cast(requestHeaders.get(SOAP_JMS_CONTENTENCODING)); +
> if (jmsEncodingHeader != null && jmsEncodingHeader.contains("gzip")) {
> + permitted = UseGzip.YES;
> + message.put(GZIP_ENCODING_KEY, "gzip");
> + }
> if (acceptEncodingHeader != null) {
> if (LOG.isLoggable(Level.FINE)) {
> LOG.fine("Accept-Encoding header: " +
> acceptEncodingHeader);
>
> Modified:
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMS
> Utils.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org
> /apache/cxf/transport/jms/JMSUtils.java?rev=1050284&r1=1050283&r2=1050284&v
> iew=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMS
> Utils.java (original) +++
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMS
> Utils.java Fri Dec 17 06:37:59 2010 @@ -48,6 +48,7 @@ import
> org.apache.cxf.common.util.SOAPCo
> import org.apache.cxf.helpers.CastUtils;
> import org.apache.cxf.helpers.HttpHeaderHelper;
> import org.apache.cxf.security.SecurityContext;
> +import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
> import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
> import org.apache.cxf.transport.jms.uri.JMSEndpoint;
> import org.apache.cxf.transport.jms.uri.JMSEndpointParser;
> @@ -245,6 +246,10 @@ public final class JMSUtils {
> messageProperties.setSOAPJMSContentType(jmsMessage
>
> .getStringProperty(JMSSpecConstants.CONTENTTYPE_FIELD)); }
> + if
> (jmsMessage.propertyExists(JMSSpecConstants.CONTENTENCODING_FIELD)) { +
> messageProperties.setSOAPJMSContentEncoding(jmsMessage +
> .getStringProperty(JMSSpecConstants.CONTENTENCODING_FIELD));
> + }
> if
> (jmsMessage.propertyExists(JMSSpecConstants.SOAPACTION_FIELD)) {
> messageProperties.setSOAPJMSSOAPAction(jmsMessage
> .getStringProperty(JMSSpecConstants.SOAPACTION_FIELD)); @@ -281,6 +286,8
> @@ public final class JMSUtils {
> // set the message encoding
> inMessage.put(org.apache.cxf.message.Message.ENCODING,
> getEncoding(contentType)); }
> +
> +
> } catch (JMSException ex) {
> throw JmsUtils.convertJmsAccessException(ex);
> }
> @@ -437,6 +444,10 @@ public final class JMSUtils {
> }
> return contentType;
> }
> +
> + public static String getContentEncoding(org.apache.cxf.message.Message
> message) { + return
> (String)message.get(GZIPOutInterceptor.GZIP_ENCODING_KEY); + }
>
> public static Message buildJMSMessageFromCXFMessage(JMSConfiguration
> jmsConfig, org.apache.cxf.message.Message outMessage, @@ -510,6 +521,11 @@
> public final class JMSUtils {
>
> jmsMessage.setStringProperty(JMSSpecConstants.CONTENTTYPE_FIELD,
> messageProperties .getSOAPJMSContentType());
> }
> +
> + if (messageProperties.isSetSOAPJMSContentEncoding()) {
> +
> jmsMessage.setStringProperty(JMSSpecConstants.CONTENTENCODING_FIELD,
> messageProperties + .getSOAPJMSContentEncoding());
> + }
>
> if (messageProperties.isSetSOAPJMSSOAPAction()) {
>
> jmsMessage.setStringProperty(JMSSpecConstants.SOAPACTION_FIELD,
> messageProperties @@ -583,6 +599,9 @@ public final class JMSUtils {
> messageProperties.setSOAPJMSBindingVersion("1.0");
> }
>
> messageProperties.setSOAPJMSContentType(getContentType(outMessage)); +
> if (getContentEncoding(outMessage) != null) {
> +
> messageProperties.setSOAPJMSContentEncoding(getContentEncoding(outMessage)
> ); + }
> String soapAction = null;
> // Retrieve or create protocol headers
> Map<String, List<String>> headers = CastUtils.cast((Map<?,
> ?>)outMessage
>
> Modified:
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spe
> c/JMSSpecConstants.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org
> /apache/cxf/transport/jms/spec/JMSSpecConstants.java?rev=1050284&r1=1050283
> &r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spe
> c/JMSSpecConstants.java (original) +++
> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spe
> c/JMSSpecConstants.java Fri Dec 17 06:37:59 2010 @@ -55,6 +55,7 @@ public
> final class JMSSpecConstants {
> public static final String SOAPACTION_PARAMETER_NAME = "soapAction";
> public static final String TARGETSERVICE_PARAMETER_NAME =
> "targetService"; public static final String CONTENTTYPE_PARAMETER_NAME =
> "contentType"; + public static final String
> CONTENTENCODING_PARAMETER_NAME = "contentEncoding"; public static final
> String ISFAULT_PARAMETER_NAME = "isFault";
>
> // JMS Field name
> @@ -64,6 +65,7 @@ public final class JMSSpecConstants {
> public static final String SOAPACTION_FIELD = SOAP_JMS_PREFIX +
> SOAPACTION_PARAMETER_NAME; public static final String TARGETSERVICE_FIELD
> = SOAP_JMS_PREFIX + TARGETSERVICE_PARAMETER_NAME; public static final
> String CONTENTTYPE_FIELD = SOAP_JMS_PREFIX + CONTENTTYPE_PARAMETER_NAME; +
> public static final String CONTENTENCODING_FIELD = SOAP_JMS_PREFIX +
> CONTENTENCODING_PARAMETER_NAME; public static final String ISFAULT_FIELD =
> SOAP_JMS_PREFIX + ISFAULT_PARAMETER_NAME;
>
> //
>
> Modified:
> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/resource
> s/schemas/wsdl/jms.xsd?rev=1050284&r1=1050283&r2=1050284&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
> (original) +++
> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd Fri
> Dec 17 06:37:59 2010 @@ -104,6 +104,7 @@
> <xs:attribute name="SOAPJMSTargetService" type="xs:string"/>
> <xs:attribute name="SOAPJMSBindingVersion" type="xs:string"/>
> <xs:attribute name="SOAPJMSContentType" type="xs:string"/>
> + <xs:attribute name="SOAPJMSContentEncoding" type="xs:string"/>
> <xs:attribute name="SOAPJMSSOAPAction" type="xs:anyURI"/>
> <xs:attribute name="SOAPJMSIsFault"
type="pt:ParameterizedBoolean"/>
> <xs:attribute name="SOAPJMSRequestURI" type="xs:string"/>
>
> Added:
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Gzi
> pServer.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/o
> rg/apache/cxf/systest/jms/GzipServer.java?rev=1050284&view=auto
> ==========================================================================
> ==== ---
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Gzi
> pServer.java (added) +++
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Gzi
> pServer.java Fri Dec 17 06:37:59 2010 @@ -0,0 +1,54 @@
> +/**
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.cxf.systest.jms;
> +
> +import javax.xml.ws.Endpoint;
> +
> +import org.apache.cxf.Bus;
> +import org.apache.cxf.BusFactory;
> +import org.apache.cxf.bus.spring.SpringBusFactory;
> +import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
> +import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
> +
> +
> +public class GzipServer extends AbstractBusTestServerBase {
> + public static final String PORT = "9000";
> //allocatePort(GzipServer.class); +
> + protected void run() {
> + Object impleDoc = new GreeterImplDoc();
> + SpringBusFactory bf = new SpringBusFactory();
> + Bus bus = bf.createBus("org/apache/cxf/systest/jms/gzipBus.xml");
> + BusFactory.setDefaultBus(bus);
> + EmbeddedJMSBrokerLauncher.updateWsdlExtensors(bus,
> "testutils/hello_world_doc_lit.wsdl"); + Endpoint.publish(null,
> impleDoc);
> + }
> +
> +
> + public static void main(String[] args) {
> + try {
> + GzipServer s = new GzipServer();
> + s.start();
> + } catch (Exception ex) {
> + ex.printStackTrace();
> + System.exit(-1);
> + } finally {
> + System.out.println("done!");
> + }
> + }
> +}
>
> Added:
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMS
> ClientServerGzipTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/o
> rg/apache/cxf/systest/jms/JMSClientServerGzipTest.java?rev=1050284&view=aut
> o
> ==========================================================================
> ==== ---
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMS
> ClientServerGzipTest.java (added) +++
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMS
> ClientServerGzipTest.java Fri Dec 17 06:37:59 2010 @@ -0,0 +1,140 @@
> +/**
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.cxf.systest.jms;
> +
> +import java.lang.reflect.UndeclaredThrowableException;
> +import java.net.URL;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +
> +import javax.xml.namespace.QName;
> +
> +import org.apache.cxf.Bus;
> +import org.apache.cxf.BusFactory;
> +import org.apache.cxf.bus.spring.SpringBusFactory;
> +import org.apache.cxf.endpoint.Client;
> +import org.apache.cxf.frontend.ClientProxy;
> +import org.apache.cxf.service.model.EndpointInfo;
> +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
> +import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
> +import org.apache.cxf.transport.jms.AddressType;
> +import org.apache.cxf.transport.jms.JMSNamingPropertyType;
> +import org.apache.hello_world_doc_lit.Greeter;
> +import org.apache.hello_world_doc_lit.PingMeFault;
> +import org.apache.hello_world_doc_lit.SOAPService2;
> +
> +import org.junit.BeforeClass;
> +import org.junit.Test;
> +
> +public class JMSClientServerGzipTest extends
> AbstractBusClientServerTestBase { + static final String JMS_PORT =
> EmbeddedJMSBrokerLauncher.PORT; + static final String PORT =
> GzipServer.PORT;
> +
> + private String wsdlString;
> +
> + @BeforeClass
> + public static void startServers() throws Exception {
> + Map<String, String> props = new HashMap<String, String>();
> + if
> (System.getProperty("org.apache.activemq.default.directory.prefix") !=
> null) { +
> props.put("org.apache.activemq.default.directory.prefix", +
> System.getProperty("org.apache.activemq.default.directory.prefix"));
> + }
> + props.put("java.util.logging.config.file",
> + System.getProperty("java.util.logging.config.file"));
> +
> + assertTrue("server did not launch correctly",
> + launchServer(EmbeddedJMSBrokerLauncher.class, props,
> null)); +
> + assertTrue("server did not launch correctly",
> + launchServer(GzipServer.class));
> +
> + }
> +
> + public URL getWSDLURL(String s) throws Exception {
> + URL u = getClass().getResource(s);
> + wsdlString = u.toString().intern();
> + EmbeddedJMSBrokerLauncher.updateWsdlExtensors(getBus(),
> wsdlString); + System.gc();
> + System.gc();
> + return u;
> + }
> + public QName getServiceName(QName q) {
> + return q;
> + }
> + public QName getPortName(QName q) {
> + return q;
> + }
> +
> + @Test
> + public void testGzipEncodingWithJms() throws Exception {
> + SpringBusFactory bf = new SpringBusFactory();
> + Bus bus = bf.createBus("org/apache/cxf/systest/jms/gzipBus.xml");
> + BusFactory.setDefaultBus(bus);
> + QName serviceName = getServiceName(new
> QName("http://apache.org/hello_world_doc_lit", +
> "SOAPService2"));
> + QName portName = getPortName(new
> QName("http://apache.org/hello_world_doc_lit", "SoapPort2")); + URL
> wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
> + assertNotNull(wsdl);
> +
> + SOAPService2 service = new SOAPService2(wsdl, serviceName);
> + assertNotNull(service);
> +
> + String response1 = new String("Hello Milestone-");
> + String response2 = new String("Bonjour");
> + try {
> + Greeter greeter = service.getPort(portName, Greeter.class);
> +
> + Client client = ClientProxy.getClient(greeter);
> + EndpointInfo ei = client.getEndpoint().getEndpointInfo();
> + AddressType address = ei.getTraversedExtensor(new
> AddressType(), AddressType.class); + JMSNamingPropertyType name
> = new JMSNamingPropertyType(); + JMSNamingPropertyType password
> = new JMSNamingPropertyType(); +
> name.setName("java.naming.security.principal");
> + name.setValue("ivan");
> + password.setName("java.naming.security.credentials");
> + password.setValue("the-terrible");
> + address.getJMSNamingProperty().add(name);
> + address.getJMSNamingProperty().add(password);
> + for (int idx = 0; idx < 5; idx++) {
> +
> + greeter.greetMeOneWay("test String");
> +
> + String greeting = greeter.greetMe("Milestone-" + idx);
> + assertNotNull("no response received from service",
> greeting); + String exResponse = response1 + idx;
> + assertEquals(exResponse, greeting);
> +
> + String reply = greeter.sayHi();
> + assertNotNull("no response received from service", reply);
> + assertEquals(response2, reply);
> +
> + try {
> + greeter.pingMe();
> + fail("Should have thrown FaultException");
> + } catch (PingMeFault ex) {
> + assertNotNull(ex.getFaultInfo());
> + }
> +
> + }
> + } catch (UndeclaredThrowableException ex) {
> + throw (Exception)ex.getCause();
> + }
> + }
> +}
>
> Added:
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzi
> pBus.xml URL:
> http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/o
> rg/apache/cxf/systest/jms/gzipBus.xml?rev=1050284&view=auto
> ==========================================================================
> ==== ---
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzi
> pBus.xml (added) +++
> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzi
> pBus.xml Fri Dec 17 06:37:59 2010 @@ -0,0 +1,47 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements. See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership. The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing,
> + software distributed under the License is distributed on an
> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + KIND, either express or implied. See the License for the
> + specific language governing permissions and limitations
> + under the License.
> +-->
> +
> +<beans xmlns="http://www.springframework.org/schema/beans"
> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> + xmlns:cxf="http://cxf.apache.org/core"
> + xmlns:jms="http://cxf.apache.org/transports/jms"
> + xsi:schemaLocation="
> +http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
> +http://cxf.apache.org/transports/jms
> http://cxf.apache.org/schemas/configuration/jms.xsd
> +http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> +
> +
> + <cxf:bus>
> + <cxf:features>
> + <bean class="org.apache.cxf.feature.LoggingFeature"/>
> + <bean
> class="org.apache.cxf.transport.common.gzip.GZIPFeature"> +
> <property name="threshold">
> + <!-- set threshold as 10 byte to ensure gzip compress
> happen for short test message--> + <value>10</value>
> + </property>
> + </bean>
> + </cxf:features>
> + </cxf:bus>
> + <jms:conduit
> name="{http://apache.org/hello_world_doc_lit}SoapPort2.jms-conduit"> +
> <!--must use binary message format for gzip compress-->
> + <jms:runtimePolicy messageType="binary"/>
> + </jms:conduit>
> +</beans>
> +
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: svn commit: r1050284 - in /cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/jms/interceptor/ rt/transports/common/src/main/java/org/apache/cxf/transport/common/gzip/ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ rt/...
Posted by Freeman Fang <fr...@gmail.com>.
Hi Dan,
Yeah, we can do it as you suggest, actually I did it this way for my
first implementation, but it introduce a header(normal
CONTENT_ENCODING header which GZIP interceptors already use) which is
not defined in SOAP over JMS spec, just not sure if it's ok for the
spec compliance.
Regards
Freeman
On 2010-12-17, at 下午10:41, Daniel Kulp wrote:
>
> Freeman,
>
>> + public static final String SOAP_JMS_CONTENTENCODING =
>> "SOAPJMS_contentEncoding";
>
> I'm a bit concerned about pushing SOAP/JMS things out beyone the
> SOAP binding.
> Is it possible to have the SOAP/JMS interceptors or similar just map
> this
> directly into the normal CONTENT_ENCODING header the GZIP
> interceptors already
> use? I think we already do that for a few headers, right?
>
> Dan
>
>
>
> On Friday 17 December 2010 1:37:59 am ffang@apache.org wrote:
>> Author: ffang
>> Date: Fri Dec 17 06:37:59 2010
>> New Revision: 1050284
>>
>> URL: http://svn.apache.org/viewvc?rev=1050284&view=rev
>> Log:
>> [CXF-3174]support gzip encoding compliant with Soap over JMS spec
>>
>> Added:
>>
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/Gzi
>> pServer.java
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/JMS
>> ClientServerGzipTest.java
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/gzi
>> pBus.xml Modified:
>>
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/JMSFaultFactory.java
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSConstants.java
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSInInterceptor.java
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPFeature.java
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPInInterceptor.java
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPOutInterceptor.java
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/JMS
>> Utils.java
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/spe
>> c/JMSSpecConstants.java
>> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
>>
>> Modified:
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/JMSFaultFactory.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/
>> apache/cxf/binding/soap/jms/interceptor/JMSFaultFactory.java?
>> rev=1050284&r1
>> =1050283&r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/JMSFaultFactory.java (original) +++
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/JMSFaultFactory.java Fri Dec 17 06:37:59 2010 @@ -43,6
>> +43,14 @@
>> public final class JMSFaultFactory {
>> return
>> createFault(SoapJMSConstants.getContentTypeMismatchQName(),
>> m); }
>>
>> + public static JMSFault createContentEncodingNotSupported(String
>> contentEncoding) { + String m = new
>> org
>> .apache.cxf.common.i18n.Message("CONTENT_ENCODING_NOT_SUPPORTED",
>> LOG,
>> + new
>> Object[] {
>> +
>> contentEncoding +
>> }).toString(); + return
>> createFault(SoapJMSConstants.getContentTypeMismatchQName(), m);
>> + }
>> +
>> public static JMSFault createMalformedRequestURIFault(String
>> requestURI) { String m = new
>> org.apache.cxf.common.i18n.Message("MALFORMED_REQUESTURI", LOG, new
>> Object[] {
>>
>> Modified:
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSConstants.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/
>> apache/cxf/binding/soap/jms/interceptor/SoapJMSConstants.java?
>> rev=1050284&r
>> 1=1050283&r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSConstants.java (original) +++
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSConstants.java Fri Dec 17 06:37:59 2010 @@ -37,6
>> +37,7 @@
>> public final class SoapJMSConstants {
>> public static final String SOAPACTION_PARAMETER_NAME =
>> "soapAction";
>> public static final String TARGETSERVICE_PARAMETER_NAME =
>> "targetService"; public static final String
>> CONTENTTYPE_PARAMETER_NAME =
>> "contentType"; + public static final String
>> CONTENTENCODING_PARAMETER_NAME = "contentEncoding"; public static
>> final
>> String ISFAULT_PARAMETER_NAME = "isFault";
>>
>> // JMS Field name
>> @@ -46,6 +47,7 @@ public final class SoapJMSConstants {
>> public static final String SOAPACTION_FIELD = SOAP_JMS_PREFIX +
>> SOAPACTION_PARAMETER_NAME; public static final String
>> TARGETSERVICE_FIELD
>> = SOAP_JMS_PREFIX + TARGETSERVICE_PARAMETER_NAME; public static final
>> String CONTENTTYPE_FIELD = SOAP_JMS_PREFIX +
>> CONTENTTYPE_PARAMETER_NAME; +
>> public static final String CONTENTENCODING_FIELD =
>> SOAP_JMS_PREFIX +
>> CONTENTENCODING_PARAMETER_NAME; public static final String
>> ISFAULT_FIELD =
>> SOAP_JMS_PREFIX + ISFAULT_PARAMETER_NAME;
>>
>> public static final String SOAP_JMS_SPECIFICIATION_TRANSPORTID =
>> "http://www.w3.org/2010/soapjms/"; @@ -53,6 +55,7 @@ public final
>> class
>> SoapJMSConstants {
>>
>> // fault codes
>> private static final String JMS_CONTENTTYPEMISMATCH_FAULT_CODE =
>> "contentTypeMismatch"; + private static final String
>> JMS_CONTENTENCODINGNOTSUPPORTED_FAULT_CODE =
>> "contentEncodingNotSupported"; private static final String
>> JMS_MALFORMEDREQUESTURI_FAULT_CODE = "malformedRequestURI"; private
>> static
>> final String JMS_MISMATCHEDSOAPACTION_FAULT_CODE =
>> "mismatchedSoapAction";
>> private static final String JMS_MISSINGCONTENTTYPE_FAULT_CODE =
>> "missingContentType"; @@ -68,6 +71,10 @@ public final class
>> SoapJMSConstants {
>> public static QName getContentTypeMismatchQName() {
>> return new QName(SOAP_JMS_NAMESPACE,
>> JMS_CONTENTTYPEMISMATCH_FAULT_CODE); }
>> +
>> + public static QName getContentEncodingNotSupportedQName() {
>> + return new QName(SOAP_JMS_NAMESPACE,
>> JMS_CONTENTENCODINGNOTSUPPORTED_FAULT_CODE); + }
>>
>> public static QName getMalformedRequestURIQName() {
>> return new QName(SOAP_JMS_NAMESPACE,
>> JMS_MALFORMEDREQUESTURI_FAULT_CODE);
>>
>> Modified:
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSInInterceptor.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/
>> apache/cxf/binding/soap/jms/interceptor/SoapJMSInInterceptor.java?
>> rev=10502
>> 84&r1=1050283&r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSInInterceptor.java (original) +++
>> cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/
>> soap/jms/i
>> nterceptor/SoapJMSInInterceptor.java Fri Dec 17 06:37:59 2010 @@
>> -47,6
>> +47,7 @@ public class SoapJMSInInterceptor extend
>> .get(Message.PROTOCOL_HEADERS));
>> if (headers != null) {
>> checkContentType(message, headers);
>> + checkContentEncoding(message, headers);
>> checkRequestURI(message, headers);
>> checkSoapAction(message, headers);
>> checkBindingVersion(message, headers);
>> @@ -58,6 +59,28 @@ public class SoapJMSInInterceptor extend
>> * @param message
>> * @param headers
>> */
>> + private void checkContentEncoding(SoapMessage message,
>> Map<String,
>> List<String>> headers) { + List<String> contentEncodingList =
>> headers.get(SoapJMSConstants.CONTENTENCODING_FIELD); +
>> JMSFault
>> jmsFault = null;
>> + if (contentEncodingList != null &&
>> contentEncodingList.size() > 0)
>> { + String contentEncoding = contentEncodingList.get(0);
>> + if (!"gzip".equals(contentEncoding)) {
>> + jmsFault =
>> JMSFaultFactory.createContentEncodingNotSupported(contentEncoding); +
>> }
>> + }
>> + if (jmsFault != null) {
>> + Fault f = createFault(message, jmsFault);
>> + if (f != null) {
>> + throw f;
>> + }
>> + }
>> + }
>> +
>> +
>> + /**
>> + * @param message
>> + * @param headers
>> + */
>> private void checkJMSMessageFormat(SoapMessage message,
>> Map<String,
>> List<String>> headers) { List<String> mt =
>> headers.get(SoapJMSConstants.JMS_MESSAGE_TYPE); if (mt != null &&
>> mt.size() > 0) {
>>
>> Modified:
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPFeature.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/common/src/main/java/
>> org/apache/cxf/transport/common/gzip/GZIPFeature.java?
>> rev=1050284&r1=105028
>> 3&r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPFeature.java (original) +++
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPFeature.java Fri Dec 17 06:37:59 2010 @@ -68,7 +68,6 @@
>> public
>> class GZIPFeature extends Abstrac
>> @Override
>> protected void initializeProvider(InterceptorProvider provider,
>> Bus
>> bus) { provider.getInInterceptors().add(IN);
>> - provider.getInFaultInterceptors().add(IN);
>> if (threshold == -1) {
>> provider.getOutInterceptors().add(OUT);
>> provider.getOutFaultInterceptors().add(OUT);
>>
>> Modified:
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPInInterceptor.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/common/src/main/java/
>> org/apache/cxf/transport/common/gzip/GZIPInInterceptor.java?
>> rev=1050284&r1=
>> 1050283&r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPInInterceptor.java (original) +++
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPInInterceptor.java Fri Dec 17 06:37:59 2010 @@ -68,6
>> +68,9 @@
>> public class GZIPInInterceptor extends A
>> if (protocolHeaders != null) {
>> List<String> contentEncoding =
>> HttpHeaderHelper.getHeader(protocolHeaders,
>> HttpHeaderHelper.CONTENT_ENCODING); + if
>> (contentEncoding ==
>> null) {
>> + contentEncoding =
>> protocolHeaders.get(GZIPOutInterceptor.SOAP_JMS_CONTENTENCODING); +
>> }
>> if (contentEncoding != null
>> && (contentEncoding.contains("gzip") ||
>> contentEncoding.contains("x-gzip"))) { try {
>>
>> Modified:
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPOutInterceptor.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/common/src/main/java/
>> org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java?
>> rev=1050284&r1
>> =1050283&r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPOutInterceptor.java (original) +++
>> cxf/trunk/rt/transports/common/src/main/java/org/apache/cxf/
>> transport/comm
>> on/gzip/GZIPOutInterceptor.java Fri Dec 17 06:37:59 2010 @@ -89,6
>> +89,8 @@
>> public class GZIPOutInterceptor extends
>> * given by the client in Accept-Encoding.
>> */
>> public static final String GZIP_ENCODING_KEY =
>> GZIPOutInterceptor.class.getName() + ".gzipEncoding"; +
>> + public static final String SOAP_JMS_CONTENTENCODING =
>> "SOAPJMS_contentEncoding";
>>
>> private static final ResourceBundle BUNDLE =
>> BundleUtils.getBundle(GZIPOutInterceptor.class); private static final
>> Logger LOG = LogUtils.getL7dLogger(GZIPOutInterceptor.class); @@
>> -165,6
>> +167,11 @@ public class GZIPOutInterceptor extends
>> if (requestHeaders != null) {
>> List<String> acceptEncodingHeader =
>> CastUtils.cast(HttpHeaderHelper .getHeader(requestHeaders,
>> HttpHeaderHelper.ACCEPT_ENCODING)); + List<String>
>> jmsEncodingHeader =
>> CastUtils.cast(requestHeaders.get(SOAP_JMS_CONTENTENCODING)); +
>> if (jmsEncodingHeader != null &&
>> jmsEncodingHeader.contains("gzip")) {
>> + permitted = UseGzip.YES;
>> + message.put(GZIP_ENCODING_KEY, "gzip");
>> + }
>> if (acceptEncodingHeader != null) {
>> if (LOG.isLoggable(Level.FINE)) {
>> LOG.fine("Accept-Encoding header: " +
>> acceptEncodingHeader);
>>
>> Modified:
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/JMS
>> Utils.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org
>> /apache/cxf/transport/jms/JMSUtils.java?
>> rev=1050284&r1=1050283&r2=1050284&v
>> iew=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/JMS
>> Utils.java (original) +++
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/JMS
>> Utils.java Fri Dec 17 06:37:59 2010 @@ -48,6 +48,7 @@ import
>> org.apache.cxf.common.util.SOAPCo
>> import org.apache.cxf.helpers.CastUtils;
>> import org.apache.cxf.helpers.HttpHeaderHelper;
>> import org.apache.cxf.security.SecurityContext;
>> +import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
>> import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
>> import org.apache.cxf.transport.jms.uri.JMSEndpoint;
>> import org.apache.cxf.transport.jms.uri.JMSEndpointParser;
>> @@ -245,6 +246,10 @@ public final class JMSUtils {
>> messageProperties.setSOAPJMSContentType(jmsMessage
>>
>> .getStringProperty(JMSSpecConstants.CONTENTTYPE_FIELD)); }
>> + if
>> (jmsMessage.propertyExists(JMSSpecConstants.CONTENTENCODING_FIELD))
>> { +
>> messageProperties.setSOAPJMSContentEncoding(jmsMessage +
>> .getStringProperty
>> (JMSSpecConstants.CONTENTENCODING_FIELD));
>> + }
>> if
>> (jmsMessage.propertyExists(JMSSpecConstants.SOAPACTION_FIELD)) {
>> messageProperties.setSOAPJMSSOAPAction(jmsMessage
>> .getStringProperty(JMSSpecConstants.SOAPACTION_FIELD)); @@ -281,6
>> +286,8
>> @@ public final class JMSUtils {
>> // set the message encoding
>>
>> inMessage.put(org.apache.cxf.message.Message.ENCODING,
>> getEncoding(contentType)); }
>> +
>> +
>> } catch (JMSException ex) {
>> throw JmsUtils.convertJmsAccessException(ex);
>> }
>> @@ -437,6 +444,10 @@ public final class JMSUtils {
>> }
>> return contentType;
>> }
>> +
>> + public static String
>> getContentEncoding(org.apache.cxf.message.Message
>> message) { + return
>> (String)message.get(GZIPOutInterceptor.GZIP_ENCODING_KEY); + }
>>
>> public static Message
>> buildJMSMessageFromCXFMessage(JMSConfiguration
>> jmsConfig, org.apache.cxf.message.Message outMessage, @@ -510,6
>> +521,11 @@
>> public final class JMSUtils {
>>
>> jmsMessage.setStringProperty(JMSSpecConstants.CONTENTTYPE_FIELD,
>> messageProperties .getSOAPJMSContentType());
>> }
>> +
>> + if (messageProperties.isSetSOAPJMSContentEncoding()) {
>> +
>> jmsMessage.setStringProperty(JMSSpecConstants.CONTENTENCODING_FIELD,
>> messageProperties + .getSOAPJMSContentEncoding());
>> + }
>>
>> if (messageProperties.isSetSOAPJMSSOAPAction()) {
>>
>> jmsMessage.setStringProperty(JMSSpecConstants.SOAPACTION_FIELD,
>> messageProperties @@ -583,6 +599,9 @@ public final class JMSUtils {
>> messageProperties.setSOAPJMSBindingVersion("1.0");
>> }
>>
>> messageProperties
>> .setSOAPJMSContentType(getContentType(outMessage)); +
>> if (getContentEncoding(outMessage) != null) {
>> +
>> messageProperties
>> .setSOAPJMSContentEncoding(getContentEncoding(outMessage)
>> ); + }
>> String soapAction = null;
>> // Retrieve or create protocol headers
>> Map<String, List<String>> headers = CastUtils.cast((Map<?,
>> ?>)outMessage
>>
>> Modified:
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/spe
>> c/JMSSpecConstants.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org
>> /apache/cxf/transport/jms/spec/JMSSpecConstants.java?
>> rev=1050284&r1=1050283
>> &r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/spe
>> c/JMSSpecConstants.java (original) +++
>> cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/
>> jms/spe
>> c/JMSSpecConstants.java Fri Dec 17 06:37:59 2010 @@ -55,6 +55,7 @@
>> public
>> final class JMSSpecConstants {
>> public static final String SOAPACTION_PARAMETER_NAME =
>> "soapAction";
>> public static final String TARGETSERVICE_PARAMETER_NAME =
>> "targetService"; public static final String
>> CONTENTTYPE_PARAMETER_NAME =
>> "contentType"; + public static final String
>> CONTENTENCODING_PARAMETER_NAME = "contentEncoding"; public static
>> final
>> String ISFAULT_PARAMETER_NAME = "isFault";
>>
>> // JMS Field name
>> @@ -64,6 +65,7 @@ public final class JMSSpecConstants {
>> public static final String SOAPACTION_FIELD = SOAP_JMS_PREFIX +
>> SOAPACTION_PARAMETER_NAME; public static final String
>> TARGETSERVICE_FIELD
>> = SOAP_JMS_PREFIX + TARGETSERVICE_PARAMETER_NAME; public static final
>> String CONTENTTYPE_FIELD = SOAP_JMS_PREFIX +
>> CONTENTTYPE_PARAMETER_NAME; +
>> public static final String CONTENTENCODING_FIELD =
>> SOAP_JMS_PREFIX +
>> CONTENTENCODING_PARAMETER_NAME; public static final String
>> ISFAULT_FIELD =
>> SOAP_JMS_PREFIX + ISFAULT_PARAMETER_NAME;
>>
>> //
>>
>> Modified:
>> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
>> URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/resource
>> s/schemas/wsdl/jms.xsd?rev=1050284&r1=1050283&r2=1050284&view=diff
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
>> (original) +++
>> cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
>> Fri
>> Dec 17 06:37:59 2010 @@ -104,6 +104,7 @@
>> <xs:attribute name="SOAPJMSTargetService" type="xs:string"/>
>> <xs:attribute name="SOAPJMSBindingVersion" type="xs:string"/>
>> <xs:attribute name="SOAPJMSContentType" type="xs:string"/>
>> + <xs:attribute name="SOAPJMSContentEncoding"
>> type="xs:string"/>
>> <xs:attribute name="SOAPJMSSOAPAction" type="xs:anyURI"/>
>> <xs:attribute name="SOAPJMSIsFault"
> type="pt:ParameterizedBoolean"/>
>> <xs:attribute name="SOAPJMSRequestURI" type="xs:string"/>
>>
>> Added:
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/Gzi
>> pServer.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/o
>> rg/apache/cxf/systest/jms/GzipServer.java?rev=1050284&view=auto
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/Gzi
>> pServer.java (added) +++
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/Gzi
>> pServer.java Fri Dec 17 06:37:59 2010 @@ -0,0 +1,54 @@
>> +/**
>> + * Licensed to the Apache Software Foundation (ASF) under one
>> + * or more contributor license agreements. See the NOTICE file
>> + * distributed with this work for additional information
>> + * regarding copyright ownership. The ASF licenses this file
>> + * to you under the Apache License, Version 2.0 (the
>> + * "License"); you may not use this file except in compliance
>> + * with the License. You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> + * software distributed under the License is distributed on an
>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + * KIND, either express or implied. See the License for the
>> + * specific language governing permissions and limitations
>> + * under the License.
>> + */
>> +package org.apache.cxf.systest.jms;
>> +
>> +import javax.xml.ws.Endpoint;
>> +
>> +import org.apache.cxf.Bus;
>> +import org.apache.cxf.BusFactory;
>> +import org.apache.cxf.bus.spring.SpringBusFactory;
>> +import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
>> +import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
>> +
>> +
>> +public class GzipServer extends AbstractBusTestServerBase {
>> + public static final String PORT = "9000";
>> //allocatePort(GzipServer.class); +
>> + protected void run() {
>> + Object impleDoc = new GreeterImplDoc();
>> + SpringBusFactory bf = new SpringBusFactory();
>> + Bus bus = bf.createBus("org/apache/cxf/systest/jms/
>> gzipBus.xml");
>> + BusFactory.setDefaultBus(bus);
>> + EmbeddedJMSBrokerLauncher.updateWsdlExtensors(bus,
>> "testutils/hello_world_doc_lit.wsdl"); +
>> Endpoint.publish(null,
>> impleDoc);
>> + }
>> +
>> +
>> + public static void main(String[] args) {
>> + try {
>> + GzipServer s = new GzipServer();
>> + s.start();
>> + } catch (Exception ex) {
>> + ex.printStackTrace();
>> + System.exit(-1);
>> + } finally {
>> + System.out.println("done!");
>> + }
>> + }
>> +}
>>
>> Added:
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/JMS
>> ClientServerGzipTest.java URL:
>> http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/o
>> rg/apache/cxf/systest/jms/JMSClientServerGzipTest.java?
>> rev=1050284&view=aut
>> o
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/JMS
>> ClientServerGzipTest.java (added) +++
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/JMS
>> ClientServerGzipTest.java Fri Dec 17 06:37:59 2010 @@ -0,0 +1,140 @@
>> +/**
>> + * Licensed to the Apache Software Foundation (ASF) under one
>> + * or more contributor license agreements. See the NOTICE file
>> + * distributed with this work for additional information
>> + * regarding copyright ownership. The ASF licenses this file
>> + * to you under the Apache License, Version 2.0 (the
>> + * "License"); you may not use this file except in compliance
>> + * with the License. You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> + * software distributed under the License is distributed on an
>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + * KIND, either express or implied. See the License for the
>> + * specific language governing permissions and limitations
>> + * under the License.
>> + */
>> +package org.apache.cxf.systest.jms;
>> +
>> +import java.lang.reflect.UndeclaredThrowableException;
>> +import java.net.URL;
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +
>> +
>> +import javax.xml.namespace.QName;
>> +
>> +import org.apache.cxf.Bus;
>> +import org.apache.cxf.BusFactory;
>> +import org.apache.cxf.bus.spring.SpringBusFactory;
>> +import org.apache.cxf.endpoint.Client;
>> +import org.apache.cxf.frontend.ClientProxy;
>> +import org.apache.cxf.service.model.EndpointInfo;
>> +import
>> org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
>> +import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
>> +import org.apache.cxf.transport.jms.AddressType;
>> +import org.apache.cxf.transport.jms.JMSNamingPropertyType;
>> +import org.apache.hello_world_doc_lit.Greeter;
>> +import org.apache.hello_world_doc_lit.PingMeFault;
>> +import org.apache.hello_world_doc_lit.SOAPService2;
>> +
>> +import org.junit.BeforeClass;
>> +import org.junit.Test;
>> +
>> +public class JMSClientServerGzipTest extends
>> AbstractBusClientServerTestBase { + static final String JMS_PORT =
>> EmbeddedJMSBrokerLauncher.PORT; + static final String PORT =
>> GzipServer.PORT;
>> +
>> + private String wsdlString;
>> +
>> + @BeforeClass
>> + public static void startServers() throws Exception {
>> + Map<String, String> props = new HashMap<String, String>();
>> + if
>> (System
>> .getProperty("org.apache.activemq.default.directory.prefix") !=
>> null) { +
>> props.put("org.apache.activemq.default.directory.prefix", +
>>
>> System.getProperty("org.apache.activemq.default.directory.prefix"));
>> + }
>> + props.put("java.util.logging.config.file",
>> +
>> System.getProperty("java.util.logging.config.file"));
>> +
>> + assertTrue("server did not launch correctly",
>> + launchServer(EmbeddedJMSBrokerLauncher.class,
>> props,
>> null)); +
>> + assertTrue("server did not launch correctly",
>> + launchServer(GzipServer.class));
>> +
>> + }
>> +
>> + public URL getWSDLURL(String s) throws Exception {
>> + URL u = getClass().getResource(s);
>> + wsdlString = u.toString().intern();
>> + EmbeddedJMSBrokerLauncher.updateWsdlExtensors(getBus(),
>> wsdlString); + System.gc();
>> + System.gc();
>> + return u;
>> + }
>> + public QName getServiceName(QName q) {
>> + return q;
>> + }
>> + public QName getPortName(QName q) {
>> + return q;
>> + }
>> +
>> + @Test
>> + public void testGzipEncodingWithJms() throws Exception {
>> + SpringBusFactory bf = new SpringBusFactory();
>> + Bus bus = bf.createBus("org/apache/cxf/systest/jms/
>> gzipBus.xml");
>> + BusFactory.setDefaultBus(bus);
>> + QName serviceName = getServiceName(new
>> QName("http://apache.org/hello_world_doc_lit", +
>> "SOAPService2"));
>> + QName portName = getPortName(new
>> QName("http://apache.org/hello_world_doc_lit", "SoapPort2"));
>> + URL
>> wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
>> + assertNotNull(wsdl);
>> +
>> + SOAPService2 service = new SOAPService2(wsdl, serviceName);
>> + assertNotNull(service);
>> +
>> + String response1 = new String("Hello Milestone-");
>> + String response2 = new String("Bonjour");
>> + try {
>> + Greeter greeter = service.getPort(portName,
>> Greeter.class);
>> +
>> + Client client = ClientProxy.getClient(greeter);
>> + EndpointInfo ei =
>> client.getEndpoint().getEndpointInfo();
>> + AddressType address = ei.getTraversedExtensor(new
>> AddressType(), AddressType.class); +
>> JMSNamingPropertyType name
>> = new JMSNamingPropertyType(); + JMSNamingPropertyType
>> password
>> = new JMSNamingPropertyType(); +
>> name.setName("java.naming.security.principal");
>> + name.setValue("ivan");
>> + password.setName("java.naming.security.credentials");
>> + password.setValue("the-terrible");
>> + address.getJMSNamingProperty().add(name);
>> + address.getJMSNamingProperty().add(password);
>> + for (int idx = 0; idx < 5; idx++) {
>> +
>> + greeter.greetMeOneWay("test String");
>> +
>> + String greeting = greeter.greetMe("Milestone-" +
>> idx);
>> + assertNotNull("no response received from service",
>> greeting); + String exResponse = response1 + idx;
>> + assertEquals(exResponse, greeting);
>> +
>> + String reply = greeter.sayHi();
>> + assertNotNull("no response received from service",
>> reply);
>> + assertEquals(response2, reply);
>> +
>> + try {
>> + greeter.pingMe();
>> + fail("Should have thrown FaultException");
>> + } catch (PingMeFault ex) {
>> + assertNotNull(ex.getFaultInfo());
>> + }
>> +
>> + }
>> + } catch (UndeclaredThrowableException ex) {
>> + throw (Exception)ex.getCause();
>> + }
>> + }
>> +}
>>
>> Added:
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/gzi
>> pBus.xml URL:
>> http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/o
>> rg/apache/cxf/systest/jms/gzipBus.xml?rev=1050284&view=auto
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> ==== ---
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/gzi
>> pBus.xml (added) +++
>> cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/
>> jms/gzi
>> pBus.xml Fri Dec 17 06:37:59 2010 @@ -0,0 +1,47 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +<!--
>> + Licensed to the Apache Software Foundation (ASF) under one
>> + or more contributor license agreements. See the NOTICE file
>> + distributed with this work for additional information
>> + regarding copyright ownership. The ASF licenses this file
>> + to you under the Apache License, Version 2.0 (the
>> + "License"); you may not use this file except in compliance
>> + with the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing,
>> + software distributed under the License is distributed on an
>> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + KIND, either express or implied. See the License for the
>> + specific language governing permissions and limitations
>> + under the License.
>> +-->
>> +
>> +<beans xmlns="http://www.springframework.org/schema/beans"
>> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> + xmlns:cxf="http://cxf.apache.org/core"
>> + xmlns:jms="http://cxf.apache.org/transports/jms"
>> + xsi:schemaLocation="
>> +http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
>> +http://cxf.apache.org/transports/jms
>> http://cxf.apache.org/schemas/configuration/jms.xsd
>> +http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> +
>> +
>> + <cxf:bus>
>> + <cxf:features>
>> + <bean class="org.apache.cxf.feature.LoggingFeature"/>
>> + <bean
>> class="org.apache.cxf.transport.common.gzip.GZIPFeature"> +
>> <property name="threshold">
>> + <!-- set threshold as 10 byte to ensure gzip
>> compress
>> happen for short test message--> + <value>10</
>> value>
>> + </property>
>> + </bean>
>> + </cxf:features>
>> + </cxf:bus>
>> + <jms:conduit
>> name="{http://apache.org/hello_world_doc_lit}SoapPort2.jms-
>> conduit"> +
>> <!--must use binary message format for gzip compress-->
>> + <jms:runtimePolicy messageType="binary"/>
>> + </jms:conduit>
>> +</beans>
>> +
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
--
Freeman Fang
------------------------
FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org