An old fashion to build Axis Web Service (2)

Maven plug-in for WSDL2Java

<project>

    <parent>

           <groupId>Hongliang.Manven.FirstHibernate.wsdl</groupId>

           <artifactId>wsdl</artifactId>

           <version>1.0-SNAPSHOT</version>

    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>Hongliang.Manven.FirstHibernate.wsdl</groupId>

    <artifactId>hibernate_server</artifactId>

    <name>hibernate_server</name>

    <version>1.0-SNAPSHOT</version>

    <build>             

<plugins>

                  <plugin>

                        <groupId>org.codehaus.mojo</groupId>

                        <artifactId>axistools-maven-plugin</artifactId>

                        <executions>

                               <execution>

                                      <goals>

                                             <goal>wsdl2java</goal>

                                      </goals>

                               </execution>

                        </executions>

                        <configuration>

                               <sourceDirectory>../</sourceDirectory>

                               <serverSide>true</serverSide>

                        </configuration>

                  </plugin>

           </plugins>

    </build>

</project>

 

The preceding code is used to create the server side code from wsdl file. If you are familiar with maven, you could realize this project is actually used a sub module of its parent module. In your parent pom file, you should have something like this

    <modules>

           <module>hibernate-server</module>

           <module>hibernate-client</module>

    </modules>

Preparing for deployment with AXIS server

You can check the Using Maven instruction to find out how to generate the web service artifact. Please also be aware of version matching for the plug-ins used for the two projects, ie Axis1.4 and Axis1.2?

 

Modify the web.xml file in the WEB-INF directory

  <servlet>

   <servlet-name>AxisServlet</servlet-name>

   <servlet-class>

     org.apache.axis.transport.http.AxisServlet

   </servlet-class>

 </servlet>

  <servlet-mapping>

   <servlet-name>AxisServlet</servlet-name>

   <url-pattern>/servlet/AxisServlet</url-pattern>

 </servlet-mapping>

 <servlet-mapping>

   <servlet-name>AxisServlet</servlet-name>

   <url-pattern>*.jws</url-pattern>

 </servlet-mapping>

 <servlet-mapping>

   <servlet-name>AxisServlet</servlet-name>

   <url-pattern>/services/*</url-pattern>

 </servlet-mapping>

 

Copy the HibernateSoapBindingImpl.java to the source folder and deploy.wsdd to the WEB-INF directory. You can change the name of HibernateSoapBindingImpl.java if you want.  

Deploying web service with AXIS

Run the installation and deploy it onto the server. Once it is done, we need to deploy the web service with AXIS.  To do that we need to run the AdminClient with deploy.wsdd file at client side. Deploy.wsdd file is deployment descriptor we want to tell Axis about. The Axis Administration Web Service lets the AdminClient program and its Ant task counterpart submit a new WSDD file for interpretation. The Axis ‘engine’ will update its configuration, then save its state. By default Axis saves it state into the global configuration file axis/WEB-INF/server-config.wsdd.

 

  • server-config.wsdd is the configuration file of the Axis Server. It contains the description of all the web services that are deployed on your server (+ some other configuration data).
  • deploy.wsdd is generated at the same time as your stubs when you use java2wsdl. deploy.wsdd is used by the deployment tool to deploy the given service. Once your service is deployed, you no longer need this file.

 

For convenience, we need to setup the classpath to run the AdminClient. You need to add all the libraries into the classpath, ie

set classpath= C:\axis\axis-1_4\lib\activation.jar;C:\axis\axis-1_4\lib\axis.jar;C:\axis\axis-1_4\lib\axis-ant.jar;C:\axis\axis-1_4\lib\commons-discovery-0.2.jar;C:\axis\axis-1_4\lib\commons-logging-1.0.4.jar;C:\axis\axis-1_4\lib\jaxrpc.jar;C:\axis\axis-1_4\lib\log4j-1.2.8.jar;C:\axis\axis-1_4\lib\saaj.jar;C:\axis\axis-1_4\lib\wsdl4j-1.5.1.jar;

 

Please be aware that there is no space allowed between to two values. To store this information permanently in WinNT/2000/XP you will need to right click on "My Computer" and select "Properties". Click the "Advanced" tab and create the new environmental variables. It is often better to use WordPad to create the variable string and then paste it into the appropriate text field.

 

Once the classpath being set, you can call the AdminClient class to deploy the web service

java org.apache.axis.client.AdminClient

     -lhttp://localhost:8080/hibernatews/services/Hibernate deploy.wsdd

 

You have to make sure the directory you are calling the following command contains the file deploy.wsdd. If you are not in this directory you will get a "java.io.FileNotFoundException: deploy.wsdd (The system cannot find the file specified)" exception.

 

This will create server-config.wsdd file in the WEB-INF and deploy the web service to the server. For further deployment, you can just copy the server-config.wsdd file to WEB-INF folder in your development directory before you wrap the project to the war file.

 

Using http://localhost:8080/hibernatews/services/Hibernate to check whether your web service is up running.

Advertisements
This entry was posted in Web Service. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s