Apache Rampart is the Axis2 module that provides WS-Security functionality to Axis2 Web services and their clients. Rampart currently implements WS-Security, WS-SecurityPolicy , WS-SecureConversation and WS-Trust specifications. In this tutorial, we will look at applying transport level security to a Web service or a client using Apache Rampart.
This page describes how to setup your development environment to compile/deploy AppFuse or StrutsResume from the command line. After setting this up, you might want to checkout HowTo Run Ant in Eclipse. This is how I currently have things setup and what I advise clients to use when we use AppFuse as a baseline for webapp development.
Table of Contents
- [1] Download - links to download the JDK, J2EE, Tomcat, Ant and MySQL
- [2] Install - detailed instructions on where to extract/install all of the above packages
- [3] Configure - how to configure your environment variables
- [4] Additional Tips - other tools I recommend using
Download [#1]
This page describes how to setup your development environment to compile/deploy AppFuse or StrutsResume from the command line. After setting this up, you might want to checkout HowTo Run Ant in Eclipse. This is how I currently have things setup and what I advise clients to use when we use AppFuse as a baseline for webapp development.
Table of Contents
- [1] Download - links to download the JDK, J2EE, Tomcat, Ant and MySQL
- [2] Install - detailed instructions on where to extract/install all of the above packages
- [3] Configure - how to configure your environment variables
- [4] Additional Tips - other tools I recommend using
Download [#1]
Edmon
Anyway, instead of creating the files one by one just download the whole project as a zip and import it in to Eclipse (or whatever you use) and it'll work fine.
"Spring framework tutorial" as part of "Java EE programming
(with Passion!)" free online course.
http://www.javapassion.com/j2ee/#Spring_Web
It does cover other Spring related topics
http://www.javapassion.com/j2ee/#Spring_framework_title
-Sang Shin
在本系列教程中我们将学习到Struts2的各种技术。在本教程中使用的工具和程序库的版本如下:
开发工具:MyEclipse6
Web服务器:Tomcat6
Struts版本:Struts2.0.11.1
JDK版本:JDK1.5.0_12
本文结合Spring 2.0开发参考手册来讲解。对于手册中有的东西我就不说了,其实这样的话也剩下不了多少我能说的了,我只是谈一下我在看手册的时候比较费劲的地方和我对这些地方的理解。
首先@AspectJ并不是AspectJ,Spring AOP 框架支持@AspectJ只是说Spring支持用AspectJ注解的方式配置AOP。当然了,Spring 2.0也支持纯的AspectJ的应用,但这个不在本文的范围之
Spring: Simple and Powerful
Spring aims to make enterprise application development as simple and productive as possible. Examples of this philosophy can be seen in Spring's approach to JDBC, ORM, JMX, dependency injection, and many other important areas of enterprise application development. Spring also distinguishes between making something simple, and making it simplistic. The elusive combination is to provide simplicity and power. One source of complexity in enterprise applications arises from the implementation of features and requirements that impact multiple parts of the application. Code relating to these features ends up scattered across the application code, making it harder to add, maintain, and understand. Spring 2.0 makes it much simpler to implement such features in a modular manner, greatly simplifying the overall application code and in some cases making it tractable to implement requirements that otherwise would just be too painful to code.
我们在使用Spring声明式事务时,有一个非常重要的概念就是事务属性。事务属性通常由事务的传播行为,事务的隔离级别,事务的超时值和事务只读标志组成。我们在进行事务划分时,需要进行事务定义,也就是配置事务的属性。
Spring在TransactionDefinition接口中定义这些属性,以供PlatfromTransactionManager使用, PlatfromTransactionManager是spring事务管理的核心接口。
Java代码
TransactionDefinition
public interface TransactionDefinition {
int getPropagationBehavior();
int getIsolationLevel();
int getTimeout();
boolean isReadOnly();
}
TransactionDefinition
public interface TransactionDefinition {
int getPropagationBehavior();
int getIsolationLevel();
int getTimeout();
boolean isReadOnly();
}
getTimeout()方法,它返回事务必须在多少秒内完成。
isReadOnly(),事务是否只读,事务管理器能够根据这个返回值进行优化,确保事务是只读的。
getIsolationLevel()方法返回事务的隔离级别,事务管理器根据它来控制另外一个事务可以看到本事务内的哪些数据。
在TransactionDefinition接口中定义了五个不同的事务隔离级别
ISOLATION_DEFAULT 这是一个PlatfromTransactionManager默认的隔离级别,使用数据库默认的事务隔离级别.另外四个与JDBC的隔离级别相对应
ISOLATION_READ_UNCOMMITTED 这是事务最低的隔离级别,它充许别外一个事务可以看到这个事务未提交的数据。这种隔离级别会产生脏读,不可重复读和幻像读。
例如:
Mary的原工资为1000,财务人员将Mary的工资改为了8000,但未提交事务
Java代码
Connection con1 = getConnection();
con.setAutoCommit(false);
update employee set salary = 8000 where empId ="Mary";
call/execution/withincode(MethodPart)-方法调用/方法执行/在方法体内,MethodPart代表方法签名,execution较常用 (call我用了,但是始终报错,还没能试出它的用法)
MethodPart的语法结构是
Java代码
[Modifier] Type [ClassType.] methodName(ArgumentType1...N...) [throws ExceptionType]
public void com.olemap.apam.dao.TestDAO.save(..) throws Exception
[Modifier] Type [ClassType.] methodName(ArgumentType1...N...) [throws ExceptionType]
public void com.olemap.apam.dao.TestDAO.save(..) throws Exception
上面的语法是对应的,需要注意的是
1.加中括号的就是可选的部分
2.'..'是指所有的参数类型
3.可以用*来代表泛指
11.3.3. Binding to Specific Ports
A web application is normally deployed to the default web container instance, and uses the network ports for that web container. However, it's possible to set up an additional web container with different network ports and other configuration settings. The web-container element can be used to associate this web application with a specific web container instance, which can have the effect of binding this web application to a different set of ports than other web applications.
SOAP and WSDL
started the biggest technology shift since the introduction of Java in 1995 and XML in 1998. SOAP is the cornerstone of what most people think of as Web ...
today.java.net/today/2003/11/05/ch4SOAP.pdf - Similar pages
Sometimes it's helpful to think of XML Namespaces as being similar to Java package names. When you create an XML Schema you are defining a type, just as a Java source file defines a type. The targetNamespace is the unique namespace of that type, just like the package name of a class defintion is the unique namespace of that type. In other words, declaring a targetNamespace in an XML Schema is the same as declaring a package name in a Java class file. It assigns the type(s) to a particular namespace.
The concept of a default namespace and a targetNamespace are orthogonal; they are separate concepts.
The default namespace has scope. If you create an XML document (be it an instance document, WSDL file, SOAP message or XML Schema) all of the elements are assumed to have unique namespaces. Usually, you will assign a prefix (a nick name) to each namespace and than tag elements that belong to that namespace with the prefix (e.g.
. However, it is possible to create a default namespace, which is the same as saying any elements without a prefix belong to a certain namespace. A default namespace is simply a namespace that is declared without a preface (e.g. xmlns="http://www.blue.com"). Default namespaces apply to the element in which they are declared and all of its children that do not use an explicit prefix.You can override a default namespace by assigning a child element a different default namespace (e.g. xmlns="http:\\www.red.com") - that element and its children that do not have an explicit prefix will become part of the new default namespace.
I hope that helps. Tried to give you a couple different ways of thinking of things.
good doc: http://www.oracle.com/technology/pub/articles/srivastava_namespaces.html
http://www.xfront.com/DefaultNamespace.pdf
The XML Namespaces Recommendation does not require element type names and attribute names to be universal names; they are also allowed to be local names. http://www.jclark.com/xml/xmlns.htm
Notice that there is no prefix. When a default namespace declaration is used on an element, all unqualified element names within its scope are automatically associated with the specified namespace identifier. Default namespace declarations, however, have absolutely no effect on attributes. The only way to associate an attribute with a namespace identifier is through a prefix.
Consider the following example:
<d:student xmlns:d='http://www.develop.com/student'Here, "student" is from the http://www.develop.com/student namespace while "name" and "rating" are from the default namespace urn:foo. The id attribute doesn't belong to a namespace since attributes aren't automatically associated with the default namespace identifier.
xmlns='urn:foo' id='3235329'
>
<name>Jeff Smith</name>
<language xmlns=''>C#</language>
<rating>35</rating>
http://msdn.microsoft.com/en-us/magazine/cc302166.aspx
</d:student>
http://www.xmlplease.com/attributexmlns
How to make JavaEE project with Maven2
- Java Module (one or more);
- EJB Module (dependent on Java Module);
- WEB Application Module (dependent on Java and EJB Modules);
- Enterprise Application Module (dependent on Java, EJB and Web Application Module).
First of all, you have to create multi-module project. It is special type of maven project - it does not produce any artifact. Its main purpose is to host modules - single maven projects - and to perform group operations for all modules.
Each single maven project should be aware of parent project. The same is true for parent maven project - it has to be aware about all the children.
Dir-A/pom.xml
=================
<dependency>
<groupId>SVU-LAP</groupId>
<artifactId>svu_lap</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/../Dir-B/src/main/webapp/WEB-INF/lib/svulap.jar</systemPath>
</dependency>
Developing open source Java applications with java.net and Eclipse
Part 1 - Creating a new project in Eclipse
Project Inheritance vs Project Aggregation
If you have several Maven projects, and they all have similar configurations, you can refactor your projects by pulling out those similar configurations and making a parent project. Thus, all you have to do is to let your Maven projects inherit that parent project, and those configurations would then be applied to all of them.
And if you have a group of projects that are built or processed together, you can create a parent project and have that parent project declare those projects as its modules. By doing so, you'd only have to build the parent and the rest will follow.
But of course, you can have both Project Inheritance and Project Aggregation. Meaning, you can have your modules specify a parent project, and at the same time, have that parent project specify those Maven projects as its modules. You'd just have to apply all three rules:
- Specify in every child POM who their parent POM is.
- Change the parent POMs packaging to the value "pom" .
- Specify in the parent POM the directories of its modules (children POMs)
I’m really new to Maven and your posted helped me get my jars deployed to an internal repository. Thanks. To help others here is the command I used:
mvn deploy:deploy-file -DgroupId=apache -DartifactId=xercesImpl -Dversion=2.5.0 -Dpackaging=jar -Dfile=./xercesImpl.jar -DrepositoryId=repository -Durl=file:///home/mike/public_html/repository
And this linked helped a lot: http://maven.apache.org/guides/mini/guide-deploying-3rd-party-jars.html
I hope my post helps others who are just getting started.
1. Introduction
Maven is a popular build tool available for java developers. One of the benefits of maven is that helps to reduce the duplication of dependent software libraries (jars) required to build an application. The maven suggested approach is to store all the software libraries in a remote store called a repository.
This brings us to a good point to compare Axis2 and CXF on their own merits. They are of course in many ways comparable; of necessity web services frameworks must fill in all the same blanks, but since both projects are very young, each has certain areas that are more well-developed than others. The chief differences are as follows:
- CXF has support for WS-Addressing, WS-Policy, WS-RM, WS-Security, and WS-I BasicProfile. Axis2 supports each of these except for WS-Policy, which will be supported in an upcoming version.
- CXF was written with Spring in mind; Axis2 is not.
- Axis2 supports a wider range of data bindings, including XMLBeans, JiBX, JaxMe and JaxBRI as well as its own native data binding, ADB. Note that support for JaxME and JaxBRI are still considered experimental in Axis2 1.2. CXF currently supports only JAXB and Aegis; support for XMLBeans, JiBX and Castor will come in CXF 2.1.
- Axis2 supports multiple languages--there is a C/C++ version available in addition to the Java version.


Apache Axis2, CXF and Sun JAX-WS RI in comparison
For the java platform there are several open source Web Service toolkits like Axis2, CXF and the JAX-WS Reference Implementation. This article describes the differences and provides decision guidance for developers and architects.
There are multiple APIs for the Java platform, e.g. for database access or web applications. The developer has to code against a standard not against a product. The particular tools and servers stay replaceable. For example a web application can be operated with both the Application Server IBM Web Sphere and the Web Container Apache Tomcat. Due to the standardization by the Java Enterprise Edition the exchange of a server can be done with little effort.
Unfortunately, Web Services are a different story. Indeed there is the JAX-WS specification, but there are still too many unanswered questions as well as alternative approaches of applying Web Services. Which SOAP implementation is suitable depends on the requirements and the environment. The sections below are describing the tools and standards that are available for developers of Web Services.
Apache Axis2
Axis 2 is the follow-up of the popular Axis1 framework. Axis2 is based on a completely new architecture and has been re-developed from scratch.
The deployment of services for Axis 1 has often been criticized. Therefore Axis 2 has a completely new deployment model. An Axis 2 runtime is a Web application and can be installed on every JEE compliant Application Server. The Axis 2 web application itself is a container for Web Services now. Web Services are packed into an own file format with the file extension aar. Due to these archives, Web Services can be installed and configured by a simple user interface at run time. In Axis 2 the services can be configured by the traditional deployment descriptors, e.g. the file services.xml.
Modules providing additional functionality, for example WS-* standard support, can also be installed during runtime. A Web Service is regarded as an independent package which can be installed into the Axis 2 runtime environment.
Writing an Axis 2 project requires a lot of knowledge about the build tool Ant. Knowledge about the build tool is essential to write an Axis 2 project. For example the WSDL2JAVA task is generating a temporary project including a build-file. Then the projects build-file has to call the generated build-file. If a Web Service uses a library, e.g. a JDBC driver, then the library has to be copied into the generated project using Ant on each build. So development with Axis 2 will be very difficult if you are not familiar with Ant.
Apache CXF
CXF is also a project of the Apache software foundation. CXF came up from a fusion of the XFire and Ionas Celtix projects.
CXF was developed with the intention to integrate it into other systems. This is reflected in CXF API and the use of the Spring framework. Therefore it is very simple to integrate CXF into existing systems.
CXF respectively its predecessor XFire was integrated into numerous open and closed source projects like ServiceMix or Mule.
A proprietary API as well as the standardized JAX-WS interface are available for the development and use of Web Services.
JAX-WS
The Java API for XML based Web Services is the successor of the JAX-RPC specification. JAX-WS respectively its predecessor is message based and supports asynchronous communication. The Configuration is managed by annotations therefore Java 5 or higher is required. JAX-WS isn't downwardly compatible to its predecessor JAX-RPC. With JAX-WS it is pretty easy to write and consume Web Services. The default values of numerous parameters are comfortable for the programmer, so that simple Pojos declared with a @WebService annotation can be used as a Service. Listing 1 shows a simple implementation of a Web Service using the @WebService annotation.
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService
public class HelloWorldService {
public String helloWorld() {
return "Hello World!";
}
}A suitable WSDL document can also be generated from the class. Other annotations can concertedly exert influence of the WSDL document. For example other namespaces or element names can be used. If JAXB is already known, its annotations can be used to define the serialization in every detail. With the contract first approach a Service Interface, JAXB annotated classes for serialization and a skeleton for the implementation can be generated. According to the WSDL document the generated classes can have numerous annotations. Annotations are also the main point of criticism of JAX-WS. Despite this criticism the JAX-WS specification came out well. It is well attuned and combinable with other Java and Java EE specifications. For example, Listing 2 shows a stateless EJB 3.0 Bean which acts as a Web Service at the same time.
@WebService
@Stateless
public class MyService{
public String hello(String name) {
return "Hallo"+name;
}
}JAX-WS Reference Implementation
The JAX-WS Reference Implementation represents the core piece of the Web Services protocol stack Metro. The Metro Stack provides support for the following Web Services standards:
- WS-Addressing
- WS-Policy
- Web Services Security aka WS-Security
- WS-Transaction
- WS-Reliable Messaging
- WS-Trust
- WS-SecureConversation
Metro is documented in detail. Apart from the JAX-WS, JAXB and JWS specifications there are numerous tutorials und samples. The Netbeans IDE as well as the tutorials of the enterprise pack makes it particularly easy to get started. Of course, Eclipse can also be used for the development with Metro.
Web applications containing Web Services which have been realized with JAX-WS are executable in the Glassfish Application Server. To make services also executable in other application servers, two libraries (JAX-WS and JAXB) have to be installed. Application servers such as JBoss, WebSphere or Tomcat can be upgraded with JAX-WS within about 10 minutes.
Performance
Due to the modern streaming XML parser, the performance of all three SOAP engines is very well. The ping time for a locale roundtrip is about 2-4 milliseconds (message size about 3KB, Dual Core Notebook). Therefore the time delay by the SOAP communication is negligible in many projects.
WS-* Standards
The support of the WS-Standard family can also be decisive for the selection of a SOAP engine. For example, messages sent to services can be secured with signatures as described in the Web Service Security standard (in short WSS). Table 1 shows the support for WS*-Standards of the toolkits.
| Standards | Axis2 | CXF | JAX-WS/Metro |
|---|---|---|---|
| WS-Addressing | X | X | X |
| WS-Coordination | X(2) | X | |
| WS-MetadataExchange | X | ||
| WS-Policy | X | X | X |
| WS-ReliableMessaging | X(3) | X | X |
| Web Services Security | X(1) | X(4) | X |
| WS-SecureConversation | X(1) | X | |
| WS-SecurityPolicy | X | ||
| WS-Transaction | X(2) | X | |
| WS-Trust | X | X | |
| WS-Federation |
Table 1: Support for WS-* Standards (stand: Juli 2008)
(1) Supported by the additional module Apache Rampart
(2) Supported by the additional module Apache Kandula2
(3) Supported by the additional module Apache Sandesha2
(4) By Apache WSS4J Interceptor
Conclusion
None of the Web Services frameworks is in general superior to the others. Axis 2 is structured modularly, has many features and can be used as an application server for Web Services. A special feature of Axis 2 is the support of removable binding frameworks, for example XMLBeans. Axis 2 together with the XMLBeans framework included is well suited for Web Services which are using very complex schema definitions. The disadvantages of Axis 2 are its complexity as well as the insufficient JAX-WS support. Therefore anyone who wants to work with JAX-WS should choose Apache CXF or the reference implementation.
Those who prefer a seamless integration with the Spring framework are well advised with the JAX-WS implementation. Furthermore CXF is slim and easy to use. CXF is the tool of choice if a SOAP engine has to be embedded into an existing software.
Who just wants to code against the standard is well advised with the JAX-WS implementation. The enterprise pack of the Netbeans development environment supports JAX-WS RI very well. Only a few clicks are needed to build a server or to call a Web Service.
I hope this article could help you with the decision for a WS toolkit.
Thomas Bayer, Marco Hippler
bayer@predic8.com hippler@predic8.com
Copyright (c) 2008 predic8 GmbH
Moltkestr. 40, 53173 Bonn, Germany, Phone: +49 (228) 555 25 76-0
prefer JAX-WS (with JAXB 2.1 databinding) over the other liberaries I've used (JAX-RPC, Axis 1 and 2, but not XFire). The JAXB 2 databinding uses generics, which makes for a pleasant mapping of properties with a maxoccurs > 1. JAX-WS itself is reasonably well documented and provides a reasonably good API. The method and parameter annotations can get a bit out of hand in some cases - XML hell in annotation form. It usually isn't so bad.
One of the nice aspects of the JAX-WS stack is project Metro, which Sun co-developed with Microsoft and interoperates well with the web service support .NET 3.0, going so far as to implement MTOM in a workable fashion.
The soap:operation element states that HTTP requests to the operation named getSummary must include a SoapAction HTTP header with the value getSummary. The soap:body elements state that the input and output messages defined in the portType form the contents of the body of a SOAP message.
I tried all given hints. It still didnt work. I experimented a bit more and here is my solution:
1) Shutdown eclipse
2) Copying the "backport-util-concurrent-3.1.jar" from "$AXIS2_HOME/lib/" to "$ECLIPSE_HOME/plugins/Axis2_Codegen_Wizard_1.3.0/lib/"
3) Adding the following into the "runtime" element "$ECLIPSE_HOME/plugins/Axis2_Codegen_Wizard_1.3.0/plugin.xml" :
4) In "$ECLIPSE_HOME/plugins/Axis2_Codegen_Wizard_1.3.0/plugin.xml" changing the version attribute of the "plugin" element from "1.3.0" to "1.4.0". This results still in the same exception. But leave it.
5) Now changing the version also in the plugin's folder name from "Axis2_Codegen_Wizard_1.3.0" to "Axis2_Codegen_Wizard_1.4.0".
6) Start eclipse and try the plugin
In my case it worked then. Hope i could help you.
Web Services Security with Apache Rampart – Part 1 ( Transport Level Security )
Submitted on February 7, 2008 - 06:28.
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("path/to/client/repo", null);
1- Direct Web Remoting
2- script.aculo.us
With DWR in few seconds you have your beans able to be used by javascript and then a lot of ui effects with the nuber 2.
I moved the cheat sheet from the blog entries to this static page. This should prevent the URL from changing.
REST vs SOAP
As you may have noticed the companies I mentioned that are using REST api's haven't been around for very long, and their apis came out this year mostly. So REST is definitely the trendy way to create a web service, if creating web services could ever be trendy (lets face it you use soap to wash, and you rest when your tired). The main advantages of REST web services are:
- Lightweight - not a lot of extra xml markup
- Human Readable Results
- Easy to build - no toolkits required
SOAP also has some advantages:
- Easy to consume - sometimes
- Rigid - type checking, adheres to a contract
- Development tools






org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [springmvc.web.HelloWorldController] for bean with name '/hello_world.html' defined in ServletContext resource [/WEB-INF/springmvc-servlet.xml]; nested exception is java.lang.ClassNotFoundException: springmvc.web.HelloWorldController.
Can someone help me out on this?