我们有一个maven 集成测试,它使用axis2 客户端 和rampart。 rampart.mar 被指定为 pom 中的依赖项,但是 Maven 并未将其包含在类路径中。 Axis 加载 rampart 模块需要 mar。
有没有人有解决办法?
pom.xml 片段:
<dependency>
<groupId>org.apache.rampart</groupId>
<artifactId>rampart</artifactId>
<version>1.4</version>
<type>mar</type>
</dependency>
最佳答案
我使用了 axis2-1.6.0 和 rampart-1.6.0 以及以下 pom 提取物:
<!-- axis2/axiom: dependencies -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-codegen</artifactId>
<version>${axis2.version}</version>
<scope>provided</scope>
</dependency>
<!-- axis2-rampart: dependencies -->
<dependency>
<groupId>org.apache.rampart</groupId>
<artifactId>rampart-core</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- slf4j: dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<!--
<scope>runtime</scope>
-->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- log4j: dependencies -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<exclusions>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
<exclusion>
<artifactId>mail</artifactId>
<groupId>javax.mail</groupId>
</exclusion>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
</exclusions>
</dependency>
<properties>
<slf4j.version>1.6.3</slf4j.version>
<log4j.version>1.2.15</log4j.version>
<axis2.version>1.6.0</axis2.version>
<rampart.version>1.6.0</rampart.version>
</properties>
但是,在作为客户端或服务器的服务使用中,您需要指定 axis2-repository 运行时位置。
// get Modulrepository
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem( AXIS2_REPOSITORY, null);
// create new Stub
Stub stub = createStub(ctx);
// configure and engage Rampart
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
// modify charset
options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING, charsetEncoding );
// // modify endpoint
// options.setTo(new org.apache.axis2.addressing.EndpointReference( ENDPOINT_LOCATION ));
// modify policies
Policy policy = loadPolicy(POLICY_FILE);
client.getAxisService().getPolicySubject().attachPolicy(policy);
实际上,由于政策验证更新不足,我在 axis2-1.6.1 上遇到了一些问题
关于java - Apache Axis2/Rampart + Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7734918/