[
https://issues.apache.org/jira/browse/AXIS2-5052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
anil bondalapati updated AXIS2-5052:
------------------------------------
Description:
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 *************************
/**
* 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;
}
****************************** SERVICE2 ************************************
/**
* 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;
}
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?
was:
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.
> 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
> Priority: Critical
> Labels: gzip
>
> 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 *************************
> /**
> * 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;
> }
> ****************************** SERVICE2 ************************************
> /**
> * 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;
> }
>
> 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?
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]