This guide explains how to use SOAP compression with Apache Axis. Both request and response messages are compressed. To compress and decompress SOAP messages on the client side, an Axis extension for gzip is used. The counterpart on the server side is a Servlet filter.
The solution presented in this document is based on Web standards and should work in conjunction with other SOAP implementations. For example, SOAP::Lite for Perl can be used as client and Axis can be used as server.
Requirements
To use this solution, a Servlet 2.3 compliant Web container, e.g. Tomcat 5, and Axis version 1.1 or higher are required. Links for downloading the Servlet filter and the Axis extension are included in this article.
Configuring the Server
The configuration of the client and the server are independent. First, you can set up and test the server. After the server configuration is working you can move on to the client side.
We will use a Servlet filter to decompress the requests and compress the responses. Although a lot of other filters can only compress the response, our free filter can both compress the response and decompress the request. To use the filter for SOAP compression, it has to be added to the Axis Web application containing the Web Services. The filter is packaged into the library 2wayfilter-1.2.jar. Download the library and copy it into the Axis Web application's lib folder.
Now, you can configure the Web application to use the filter. Include the following filter and filter-mapping elements in the Web application's deployment descriptor. The deployment descriptor is in the file web.xml in the folder WEB-INF.
<web-app> ... <filter> <filter-name>2WayFilter</filter-name> <filter-class>com.osmoticweb.gzipfilter.GZIP2WayFilter</filter-class> </filter> <filter-mapping> <filter-name>2WayFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ... </web-app>
Restart the Web application. For example, by shutting down and restarting Tomcat.
After restarting the Web application, the configuration can be tested. A simple Web page inside the Web application is needed for the test. The Axis index page will work.
Hint: If there is no suitable page inside the Web application, just copy a static HTML file into the Web application's root directory.
To run the test, the index page is requested from the Web browser. To see if the configuration is working, the messages between client and server have to be intercepted and displayed. Tcpmon is a standalone utility included in the Axis distribution. For this How-To, tcpmon will serve as the interceptor to show the exchanged HTTP messages.
The tcpmon utility requires the axis.jar library in the classpath. Tcpmon can be started from the command line.
java org.apache.axis.utils.tcpmon
After starting tcpmon, a new session can be added to intercept our calls. For the test, we will use listen port 2000. The session will act as a listener for the target host 127.0.0.1 on target port8080. See the screenshot below.
Now the test page can be requested from a Web browser that supports HTTP compression, for example, Mozilla, Firefox and Microsoft Internet Explorer.
To use the interceptor, the URL of the test page has to be modified. Instead of port 8080, we will use port 2000 on which the tcpmon session is listening. The page should be rendered the same way as it would without the interceptor.
The request and response message can now be examined in tcpmon. The request message should contain an Accept-Encoding header field containing the value gzip to indicate that the browser will accept gzip compressed responses. The compression Servlet filter on the server side should have recognized this field and compressed the response. The header of a compressed response message remains uncompressed and contains a Content-Encodingheader field indicating the encoding algorithm. The body is compressed and appears in the monitor as a strange looking string instead of a plaintext message.
Configuring the Client
To use the compression feature of the server, the client must be able to compress requests and decompress responses. Apache Axis can be extended with the SOAP compression transport sender which supports compression and decompression of SOAP messages. The extension can be installed without recompiling or modifying Axis itself.
Download the library soap-compression-1.2.jar containing the extension and place it into the classpath of the Axis client. The library contains the classcom.osmoticweb.soapcompression.CompressionHTTPSender which can be used instead of the built-in sender. To instruct the Axis client to use the new class a client side deployment descriptor is necessary. Create a file named client-config.wsdd, with the following content, and place it in the directory where the Axis client is started. See the Axis WSDD Reference for more details about the deployment descriptor.
The compression sender is compatible with Axis 1.1 or newer. The configuration is different depending on which version of Axis is used. The difference lies in how parameters are declared in the file client-config.wsdd. Use the corresponding configuration for your Axis version. For details see the SOAP compression sender description.
Axis 1.2 Beta or Newer
<?xml version="1.0" encoding="UTF-8"?> <deployment name="defaultClientConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <transport name="http" pivot="java:com.osmoticweb.soapcompression.CompressionHTTPSender"> <parameter name="compressRequest" value="true"/> <parameter name="acceptEncodingHeader" value="true"/> </transport> <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/> <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/> </deployment>
Axis 1.1
<?xml version="1.0" encoding="UTF-8"?> <deployment name="defaultClientConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <transport name="http" pivot="java:com.osmoticweb.soapcompression.CompressionHTTPSender"> <requestFlow> <handler type="java:com.osmoticweb.soapcompression.PutOptionsHandler"> <parameter name="compressRequest" value="true"/> <parameter name="acceptEncodingHeader" value="true"/> </handler> </requestFlow> </transport> <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/> <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/> </deployment>
Turning Compression On and Off
The compression of the request and the decompression of the response can be configured separately using parameter elements inside the transport element. To turn on compression of requests, set the parameter compressRequest to true. To get compressed responses the client has to tell the server that it accepts encoded messages using the Accept-Encoding header field. The acceptEncodingHeader parameter causes the client to send the Accept-Encodingheader with a value of "gzip".
To test the installation you can use the following client for the Version Web Service. This pre-configured Web Service is part of the Axis Web application included in the Axis distribution.
package com.osmoticweb.soapcompression; import javax.xml.namespace.QName; import javax.xml.rpc.*; public class GetVersionClient { private static String endpoint= "http://localhost:2000/axis/services/Version";; public static void main(String[] args) throws Exception { ServiceFactory sf = ServiceFactory.newInstance(); Service service = sf.createService(null); Call call = service.createCall(); call.setTargetEndpointAddress(endpoint); call.setOperationName(new QName("http://localhost:8080/axis/services/Version", "getVersion")); System.out.println(call.invoke(new Object[] {})); } }
The endpoint of this client points to tcpmon on port 2000 in order to intercept the calls to the server. Don't be confused because the namespace for the operation is different from the endpoint URL.
If everything is done correctly, you should see messages like the ones in the screenshot below. The request and the response are compressed. The request message contains an Accept-Encoding header and both contain a Content-Encoding header.
Troubleshooting
If the solution is not working, check to see if a firewall is configured on the client or server. We found that the Norton firewall modifies the Accept-Encoding header, which disables the compression, in order to inspect HTTP communication for security purposes.
Summary
In real world applications, performance is an issue, especially if a large amount of data has to be exchanged. The XML representation of data in SOAP messages inflates the data transferred, thus reducing speed. SOAP compression alleviates this obstacle without giving up the advantages of XML. There is little difference between binary remote protocols and compressed SOAP messages when it comes to transmission performance.
相关推荐
shibboleth-sp-2.5.3-win32.msi
** Shibboleth IDP 配置与服务提供者(SP)集成详解 ** Shibboleth Identity Provider(IDP)是 Shibboleth 身份联盟框架中的核心组件,用于管理和验证用户身份,并向服务提供者(Service Provider, SP)提供身份...
sso模拟,服务端的安装 ,shibboleth-sp-2.5.2-win32.msi
Shibboleth软件工具广泛使用联合的身份标准,主要是OASIS安全声称标记语言(SAML),来提供一个联合单点登录和属性交换框架。一个用户用他的组织的证书认证,组织(或IdP)传送最少的必要的身份信息给SP实现认证决定...
《Python库Shibboleth-0.6.0-py3-none-any.whl:深入了解与应用》 在Python的世界里,库是开发者的重要工具,它们提供了丰富的功能,使得编程工作更加高效便捷。本文将深入探讨名为"Shibboleth"的Python库,特别是...
Shibboleth是一款广泛应用于身份验证和授权领域的开源软件,主要设计用于教育和研究机构,但也适用于其他需要安全Web服务的企业或组织。标题中的"shibboleth-idp-2.0.0-bin.zip"表明这是一个针对Shibboleth Identity...
Shibboleth是一款广泛用于身份验证和授权的开源软件,主要在教育和研究机构中用于实现单点登录(Single Sign-On, SSO)服务。它分为两个主要组件:Identity Provider (IdP) 和 Service Provider (SP)。在这个场景中...
shibboleth-idpv3-duo 这是 Shibboleth 身份提供程序版本 3.x 的身份验证模块。 它提供 Duo Security 身份验证。 注意这是一项正在进行的工作,它甚至还不能工作,而且很可能无法编译。 安装 duo.vm 转到视图 Duo-...
资源来自pypi官网。 资源全名:shibboleth-0.6.0-py3-none-any.whl
shibboleth.part2
shibboleth_django-freeradius_login 该项目实现了Java的JAAS LoginModule,它允许Shibboleth idp服务器使用模块进行身份验证。 要求 该项目与Shibboleth idp服务器和django-freeradius模块一起使用,因此请参见...
Shibboleth IdP 安装程序模板用于安装模板,该模板使用进行外部 SSO 身份验证。 shibboleth 安装程序预先配置并装饰有额外的任务,这些任务将提供一个准备好部署的全功能身份提供者。特征一种更自动化的安装 ...
这是Internet2多上下文代理项目。 该项目实现了Shibboleth v2登录处理程序,该处理程序提供了对用户可能使用的身份验证上下文的更多控制。 可以在Shibboleth Wiki的Contributions区域下找到详细的用法。
《Shibboleth安装与配置CAS验证源详解》 Shibboleth和CAS(Central Authentication Service)是两个在身份认证领域广泛使用的系统。Shibboleth是一个基于SAML(Security Assertion Markup Language)的身份提供者...
目前,主要的联合认证协议包括SAML、Liberty和WS-Federation等,这些协议虽然大大简化了用户的认证过程,但也引发了安全和隐私方面的关注。由于联合认证协议涉及大量的用户信息交换,确保这些信息在传递过程中的安全...
Shibboleth IdP 安装程序模板用于安装模板,该模板使用于外部 SSO 身份验证。 shibboleth 安装程序预先配置并装饰有额外的任务,这些任务将提供一个准备好部署的全功能身份提供者。特征一种更自动化的安装 ...
而Shibboleth则是一种广泛用于Web身份验证和授权的系统,它在教育和研究机构中尤其常见。当我们需要在多个服务器上部署和配置Shibboleth服务时,Ansible的威力就得到了充分展现。本文将深入探讨如何使用Ansible来...
设计Shibboleth-IDP主题 Shibboleth IdP> 3.2的Bootstrap Italia模板 Shibboleth身份提供程序(IdP版本> 3.2)CSS / html模板,建立在。 该项目通过Designers Italia 定义的模式和组件继承了定义的所有功能,组件,...
Shibboleth IdP目录 概述用于管理Shibboleth IdP的人偶模块 模块说明这 ... 设置 IdP会产生什么影响... 设置要求只需要安装模块 从IdP开始最小设置: class { 'shibboleth_idp' : } 用法 自定义IdP选项 class { '...