axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hendy Irawan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AXIS2-2376) Make it optional to output indented XML from Axis2
Date Sat, 28 Apr 2012 20:42:49 GMT

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

Hendy Irawan commented on AXIS2-2376:
-------------------------------------

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: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


Mime
View raw message