You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Andreas Veithen (JIRA)" <ji...@apache.org> on 2017/01/18 23:07:26 UTC

[jira] [Resolved] (AXIS2-5052) Unable to send compressed message!!

     [ https://issues.apache.org/jira/browse/AXIS2-5052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Veithen resolved AXIS2-5052.
------------------------------------
       Resolution: Fixed
         Assignee: Andreas Veithen
    Fix Version/s: 1.8.0

> Unable to send compressed message!!
> -----------------------------------
>
>                 Key: AXIS2-5052
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5052
>             Project: Axis2
>          Issue Type: Bug
>          Components: client-api
>    Affects Versions: 1.5.4
>         Environment: Windows xp, 
>            Reporter: anil bondalapati
>            Assignee: Andreas Veithen
>              Labels: gzip
>             Fix For: 1.8.0
>
>
> Hi, 
> I have two webservices deployed on two different servers. (service1 and service2) 
> From my client program I have enabled the GZIP format on the request for the serviceClient. 
> When I make a call to the service1, the message is compressed and sent to the server and everything looks good. 
> After some time I made a call to the service2 and the request xml is sent in compressed format and looks fine. 
> But Now if I sent the message to the service1, it is in clear text and not using the compressed format. 
> Am I missing any options on the ServiceClient. Please let me know if you have faced this problem. 
> Here is the code I am using: 
>       &a! mp;n! bsp;            HttpMethodRetryHandler retry_handler = new DefaultHttpMethodRetryHandler(0, false); 
>                     HttpClientParams params = new HttpClientParams(); 
>                     params.setParameter(HttpMethodParams.RETRY_HANDLER, retry_handler); 
>                     options.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, new org.apache.commons.httpclient.HttpClient(params, manager)); 
>                 options.setProperty(HTTPConstants.MC_GZIP_REQUEST, true); 
>                 options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true); 
>                 options.setProperty(HTTPConstants.MC_GZIP_RESPONSE, true); 
>             &! nbsp;!     options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true); 
>               
>                 options.setTimeOutInMilliSeconds(wsTimeOutInMilliSeconds); 
>                 options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, wsTimeOutInMilliSeconds); 
>                 options.setCallTransportCleanup(true); 
> Any help is greatly appreciated.
> Thanks
> Anil.
> After debugging the source code I Have found that in AxisRequestEntity.java at line # 80,  the condition is also looking for CHUNKED flag. Is this a must if you want to enable gzip on request?
>  if (gzip != null && JavaUtils.isTrueExplicitly(gzip) && chunked) {
>             outStream = new GZIPOutputStream(outStream);
>         }
> I have another question:
> THis is the code where I create an instance of the sub.
> *SERVICE 1*
> {code}
>     /**
>      * Returns (new or existing) reference to Web Service TransactionManager.
>      * @return TransactionManager
>      */
>     public TransactionManagerStub getTransactionManagerStub(TransactionManagerStub stub, boolean retry, boolean compressMessage) throws Exception
>     {
>         if (stub == null)
>         {
>             try
>             {
>                 String url      = Gateway.getProperty("application", "TransactionWSUrl", "");
>                 String user     = Gateway.getProperty("application", "WebserviceUser", "");
>                 String password = Gateway.getProperty("application", "WebservicePasswd", "");
>                 int wsTimeOutInMilliSeconds = Integer.parseInt(Gateway.getProperty("application", "wsTimeOutInMilliSeconds", ""));
>                 if (logger.isDebugEnabled())
>                     logger.debug(url);
>                 stub = new TransactionManagerStub(url);
>                 ServiceClient sc = stub._getServiceClient();
>                 sc.cleanup();
>                 // Set security options
>                 org.apache.axis2.client.Options options = sc.getOptions();
>                 options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(AXIS2_RAMPART_POLICY));
>                 MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
>                 if(!retry)
>                 {
>     	            //This logic will turn off retry attempts. By default Axis2 will retry for 3 attempts which
>     	            // results in sending the same message for three times and the application will throw duplicate key exceptions.
>                     HttpMethodRetryHandler retry_handler = new DefaultHttpMethodRetryHandler(0, false);
>                     HttpClientParams params = new HttpClientParams();
>                     params.setParameter(HttpMethodParams.RETRY_HANDLER, retry_handler);
>                     options.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, new org.apache.commons.httpclient.HttpClient(params, manager));
>                 } 
>                 else
>                 {
>                     options.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, new org.apache.commons.httpclient.HttpClient(manager));
>                 }
>                 if(compressMessage)
>                 {
>                 	options.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
>                 	options.setProperty(HTTPConstants.CHUNKED, true);
>                 }
>                 options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true);
>                 options.setTimeOutInMilliSeconds(wsTimeOutInMilliSeconds);
>                 options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, wsTimeOutInMilliSeconds);
>                 options.setCallTransportCleanup(true);
>                 options.setUserName(user);
>                 StringEncryptionUtility util = new StringEncryptionUtility();
>                 char[] pwd = util.getCSFPassword(password);
>                 options.setPassword(new String(pwd));
>                 Util.flushCharArray(pwd);
>                 sc.setOptions(options);
>                 // Enable axis2 security module
>                 sc.engageModule(AXIS2_SECURITY_MODULE);
>                 stub._setServiceClient(sc);
>             }
>             catch (Exception t)
>             {
>                 t.printStackTrace();
>                 logger.error(t);
>                 throw t;
>             }
>         }
>         
>         ServiceClient sc = stub._getServiceClient();
> //        // Set security options
>         org.apache.axis2.client.Options options = sc.getOptions();
>         if(compressMessage)
>         {
>         	options.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
>         	options.setProperty(HTTPConstants.CHUNKED, true);
> //        	options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);
> //        	options.setProperty(HTTPConstants.MC_GZIP_RESPONSE, true);
> //        	
> //        	
> //        	options.setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
> //        	options.setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
> //        	options.setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_RESPONSE,Boolean.TRUE);
> //        	options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COMPRESSION_GZIP,Boolean.TRUE);
> //        	options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
>         	
>         }
>         sc.setOptions(options);
>         stub._setServiceClient(sc);
>         
>         return stub;
>     }   
> {code}
> *SERVICE2*
> {code}
>     /**
>      * Returns (new or existing) reference to Web Services' ReturnsManager.
>      * @return ReturnsManager
>      */
>     private ReturnsManagerStub getWSReturnsManager()
>     {
>         if (wsReturnsMgr == null)
>         {
>             try
>             {
>                 wsReturnsMgr = new ReturnsManagerStub(protocol + "://" + getReturnsManagerServerName() + ":"
>                         + getReturnsManagerServerPort() + path);
>                 ServiceClient sc = wsReturnsMgr._getServiceClient();
>                 // Set security options
>                 Options options = sc.getOptions();
>                 options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(getWebServiceSecurityPolicy()));
>                 MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
>                 options.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, new org.apache.commons.httpclient.HttpClient(manager));
>                 options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true);
>                 options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, getTimeOutInMilliSeconds());
>                 if(isCompressionAllowed())
>                 {
> 	            	options.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
> //	            	options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);
> //	            	options.setProperty(HTTPConstants.MC_GZIP_RESPONSE, true);
>                 }
>                 options.setTimeOutInMilliSeconds(getTimeOutInMilliSeconds());
>                 options.setCallTransportCleanup(true);
>                 options.setUserName(getWebServiceUser());
>                 char[] pwd = getWebServicePassword();
>                 options.setPassword(new String(pwd));
>                 Util.flushCharArray(pwd);
>                 sc.setOptions(options);
>                 // Enable axis2 security module
>                 sc.engageModule(AXIS2_SECURITY_MODULE);
>                 wsReturnsMgr._setServiceClient(sc);
>             }
>             catch (Throwable t)
>             {
>               logger.error("Unable to properly initialize the ReturnsManager webservice.", t);
>             }
>         }
>         return wsReturnsMgr;
>     }
>  {code}
> The above method is defined in  a class EnterpriseWebserviceOperation.java and I am creating multiple instances of it for every action to be called with in the webservice. I am doing this with the assumption that some of the actions are called very frequently and if there is only one instance of stub, that may cause denial of service.  Is it a good idea to create multiple instances of stub for every action? Even if you create multiple instances, the underlying axis2 api will use only one instance of MultiThreadedHttpConnectionManager?
> As I have told you before I have two servcies deployed on two servers and from the client which is running in  a single JVM, for one service I send the request xml as compressed and for the othere service send the clear text xml. After sending the request xml to service2 in clear text, immediately after that we will send the outcome of the previous service to the other service in compression format. Do these multiple service calls use the same MultiThreadedHttpConnectionManager and the options get overridden? 
> I have also another concern here, this service is running at a corporate level and all the stores will be sending the sale transactions to this corporate server. If there are around 500 stores and if the TPS is 500 sent to this webservice, will the service be able to handle that many requests or will the server die? Currently we are using JMS for sending these transactions and my plan is to introduce webservice layer to send the transactions. will this approach work or are we going end up with scalability issues?
> Another issue under the same context, the response is not compressed after setting the following code. Do I have to do anything on the server side to allow the compression for the response.
> We are using Websphere and Weblogic application servers.
>                 	options.setProperty(HTTPConstants.MC_GZIP_RESPONSE, true);
>                 	options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org