[ 
https://issues.apache.org/jira/browse/AXIS2-2376?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13264397#comment-13264397
 ] 

Hendy Irawan edited comment on AXIS2-2376 at 4/28/12 8:42 PM:
--------------------------------------------------------------

This is how I did it in magja with Axis2 1.6.2 ( 
https://github.com/magja/magja/commit/7f34d681a514f542bb36a005f792e5b5081167c6 
) :

{code}
        connectOptions = new Options();
        connectOptions.setTo(new EndpointReference(config.getRemoteHost()));
        connectOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        connectOptions.setTimeOutInMilliSeconds(60000);
        connectOptions.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
        connectOptions.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);

        // to use the same tcp connection for multiple calls
        // workaround:
        // 
http://amilachinthaka.blogspot.com/2009/05/improving-axis2-client-http-transport.html
        MultiThreadedHttpConnectionManager httpConnectionManager = new 
MultiThreadedHttpConnectionManager();
        HttpClient httpClient = new HttpClient(httpConnectionManager);
        connectOptions.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
                Constants.VALUE_TRUE);
        connectOptions
                .setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
        connectOptions.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION,
                HTTPConstants.HEADER_PROTOCOL_10);

        // Useful during HTTP debugging
//              HttpTransportProperties.ProxyProperties proxyProps = new 
HttpTransportProperties.ProxyProperties();
//              proxyProps.setProxyName("localhost");
//              proxyProps.setProxyPort(8008);
//              proxyProps.setUserName("guest");
//              proxyProps.setPassWord("guest");
//              connectOptions.setProperty(HTTPConstants.PROXY, proxyProps);
        
        sender = new ServiceClient();
        sender.setOptions(connectOptions);

        
sender.getServiceContext().setProperty(Constants.Configuration.MESSAGE_FORMATTER,
 new SOAPMessageFormatter() {
                @Override
                public String formatSOAPAction(MessageContext msgCtxt,
                                OMOutputFormat format, String soapActionString) 
{
                        format.setStAXWriterConfiguration(new 
StAXWriterConfiguration() {
                                        @Override
                                        public XMLOutputFactory 
configure(XMLOutputFactory factory,
                                                        StAXDialect dialect) {
                                                StaxUtilsXMLOutputFactory 
indentingFactory = new StaxUtilsXMLOutputFactory(factory);
                                                
indentingFactory.setProperty(StaxUtilsXMLOutputFactory.INDENTING, true);
                                                return indentingFactory;
                                        }
                                });
                        return super.formatSOAPAction(msgCtxt, format, 
soapActionString);
                }
        });
{code}

For the record, it works wonderfully.

Tip: Enable gzip compression for both request and accept, and save lots of 
bandwidth :-)
                
      was (Author: ceefour):
    This is how I did it in magja ( 
https://github.com/magja/magja/commit/7f34d681a514f542bb36a005f792e5b5081167c6 
) :


        connectOptions = new Options();
        connectOptions.setTo(new EndpointReference(config.getRemoteHost()));
        connectOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        connectOptions.setTimeOutInMilliSeconds(60000);
        connectOptions.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
        connectOptions.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);

        // to use the same tcp connection for multiple calls
        // workaround:
        // 
http://amilachinthaka.blogspot.com/2009/05/improving-axis2-client-http-transport.html
        MultiThreadedHttpConnectionManager httpConnectionManager = new 
MultiThreadedHttpConnectionManager();
        HttpClient httpClient = new HttpClient(httpConnectionManager);
        connectOptions.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
                Constants.VALUE_TRUE);
        connectOptions
                .setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
        connectOptions.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION,
                HTTPConstants.HEADER_PROTOCOL_10);

        // Useful during HTTP debugging
//              HttpTransportProperties.ProxyProperties proxyProps = new 
HttpTransportProperties.ProxyProperties();
//              proxyProps.setProxyName("localhost");
//              proxyProps.setProxyPort(8008);
//              proxyProps.setUserName("guest");
//              proxyProps.setPassWord("guest");
//              connectOptions.setProperty(HTTPConstants.PROXY, proxyProps);
        
        sender = new ServiceClient();
        sender.setOptions(connectOptions);

        
sender.getServiceContext().setProperty(Constants.Configuration.MESSAGE_FORMATTER,
 new SOAPMessageFormatter() {
                @Override
                public String formatSOAPAction(MessageContext msgCtxt,
                                OMOutputFormat format, String soapActionString) 
{
                        format.setStAXWriterConfiguration(new 
StAXWriterConfiguration() {
                                        @Override
                                        public XMLOutputFactory 
configure(XMLOutputFactory factory,
                                                        StAXDialect dialect) {
                                                StaxUtilsXMLOutputFactory 
indentingFactory = new StaxUtilsXMLOutputFactory(factory);
                                                
indentingFactory.setProperty(StaxUtilsXMLOutputFactory.INDENTING, true);
                                                return indentingFactory;
                                        }
                                });
                        return super.formatSOAPAction(msgCtxt, format, 
soapActionString);
                }
        });

For the record, it works wonderfully.

Tip: Enable gzip compression for both request and accept, and save lots of 
bandwidth :-)
                  
> Make it optional to output indented XML from Axis2
> --------------------------------------------------
>
>                 Key: AXIS2-2376
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2376
>             Project: Axis2
>          Issue Type: Improvement
>    Affects Versions: 1.1.1
>            Reporter: Jonas Boëthius
>            Priority: Minor
>
> For readability of XML, and therefore also helping the initial integration 
> towards a web service, it would be good to be able to e.g. configure the 
> server side to return indented ("pretty printed") XML. From what I know, 
> there is no specific recommendation against indenting XML in SOAP (like WS-I 
> etc). Axis version 1.1 returned indented XML by default.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
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]

Reply via email to