Securing Spring Web Services: Chapter7

Adding Securities Dependencies in pom.xml to build Project


1.    Here we will see how to add spring ws core and spring ws security dependencies in pom.xml. We can add dependencies in pom as shown in the following xml.

Note that spring ws security depends on Sun Java Streaming XML parser hence it has to be added as a dependency.

Also we have to configure exec-maven-plugin in the build tag to run App.java we created in earlier chapter.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <groupId>com.bookstore.client</groupId>
       <artifactId>bookstore-web-service-client</artifactId>
       <packaging>jar</packaging>
       <version>1.0-SNAPSHOT</version>
       <name>bookstore-web-service-client</name>
       <url>http://maven.apache.org</url>
       <dependencies>
              <dependency>
                     <groupId>junit</groupId>
                     <artifactId>junit</artifactId>
                     <version>3.8.1</version>
                     <scope>test</scope>
              </dependency>
              <dependency>
                     <groupId>org.springframework.ws</groupId>
                     <artifactId>spring-ws-core</artifactId>
                     <version>2.1.1.RELEASE</version>
              </dependency>
              <dependency>
                     <groupId>org.springframework.ws</groupId>
                     <artifactId>spring-ws-security</artifactId>
                     <version>2.1.2.RELEASE</version>
              </dependency>
            <!-- spring-ws-security depends on Sun Java Streaming XML Parser -->
              <dependency>
                     <groupId>com.sun.xml.stream</groupId>
                     <artifactId>sjsxp</artifactId>
                     <version>1.0.2</version>
              </dependency>
       </dependencies>
       <build>
              <plugins>
                     <plugin>
                           <artifactId>maven-compiler-plugin</artifactId>
                           <version>2.0.2</version>
                           <configuration>
                                  <source>1.6</source>
                                  <target>1.6</target>
                           </configuration>
                     </plugin>
                     <plugin>
                           <groupId>org.codehaus.mojo</groupId>
                           <artifactId>exec-maven-plugin</artifactId>
                           <configuration>
                                  <mainClass>com.bookstore.client.App</mainClass>
                           </configuration>
                     </plugin>
              </plugins>
       </build>
</project>

2.       Run the following command from bookstore-web-service-client directory to run the client to test the web service. we will use the add and delete the book request and check the security is working fine.

mvn clean package exec:java

You should see the following output:

Add Request: Book Added Successfully
Get Request: [Name=Spring Web Service, Author=XYZ, price=ABC]
Delete Request: Book Deleted Successfully

No comments :

Post a Comment