集成Axis and Appfuse part1 http://spaces.msn.com/members/chenztw/PersonalSpace.aspx?_c=
Introduction
这个练习的目的是为了说明如何集成Apache Axis into Appfuse
第一部分,我们增加一些lib与jsp
第二部分,我们将从appfuse的服务层提供webservice,然后做一个简单的测试
Step 0. Check out Envirenment.配置你的环境
开始之前,请确认你已有以下的工具
注意: 在Tomcat 4.x and Java1.4中,你可能需要将一些包含java.* or javax.*的包拷贝到CATALINA_HOME/common/lib, jaxrpc.jar and saaj.jar也是需要的。(Axis提到过)
注意: (October 5,2005): Axis 1.3 Final 已经发布. 如果你喜欢,你可以使用1.3版的
注意:: 想知道怎样让AppFuse工程在Eclipse中run起来,可以上appfuse的网站
注意: 关于怎样安装axis,你可以查看axis的安装说明. 我建议你在先安装axis,看看是否在tomcat中成功运行.
为了集成ant任务到appfuse, 我们需要axis-tasks.properties.
That's all we need. 这些都是我们需要做的。
You can check the screen here..
3. 修改appfuse工程的lib/lib.properties ,增加以下
#
# Axis - http://ws.apache.org/axis/
#
axis.version=<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.1
axis.dir=${lib.dir}/axis-${axis.version}
You can check the screen here.
4.修改appfuse工程的根目录下的properties.xml,增加以下到<project>标签中
<!-- Axis Classpath -->
<path id="axis.classpath">
<path refid="xdoclet.classpath"/>
<fileset dir="${axis.dir}" includes="*.jar"/>
<fileset dir="${javamail.dir}" includes="*.jar"/>
</path>
You can check the screen here.
5. 修改build.xml,增加以下到package-web target中
<!-- axis lib -->
<lib dir="${axis.dir}" includes="*.jar"/>
You can check the screen here.
关于怎样增加libs到appfuse中可以查看here.
注意: 除了第4步,所有的步骤都差不多。在第三步前,我建议你在appfuse中运行ant setup-tomcat deploy. 如果一切ok, 你将发些axis相关的jars已经copy到你的tomcat webapps\appfuse\WEB-INF\lib下了
第三步 修改相关的web.xml设置
All these files needed to modified should be found under \metadata\web in you appfuse project.
1. Modify listeners.xml and add
这些需要修改的文件都可以在appfuse工程\metadata\web下找到
1. 修改listeners.xml ,增加以下
<!-- axis -->
<listener>
<listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
</listener>
You can check the screen here.
2. Create xml file name mime-mappings.xml and add to \metadata\web path
2,生成文件mime-mappings.xml然后增加到\metadata\web
<!-- axis -->
<!-- currently the W<chmetcnv w:st="on" unitname="C" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0"></chmetcnv>3C havent settled on a media type for WSDL;
http://www.w3.org/TR/2003/WD-wsdl12-20030303/#ietf-draft
for now we go with the basic 'it's XML' response -->
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
You can check the screen here.
3. Modify servlet-mappings.xml and add
3. 修改servlet-mappings.xml, 增加以下
<!-- axis -->
<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>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<!-- uncomment this if you want the admin servlet -->
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
You can check the screen here.
Note : Here we uncomment AdminServlet servlet setting to use axis AdminServlet.
If you do not need this, just mark it up. Default Axis distribution mark it up.
4. Modify servlets.xml and add
<!-- axis -->
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>Axis Admin Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AdminServlet
</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<display-name>SOAPMonitorService</display-name>
<servlet-class>
org.apache.axis.monitor.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
You can check the screen here.
第四步. Copy axis related jsps into appfuse
1. Copy list files below to appfuse. You can find these files in axis-1_2_1\webapps\axis path in axis distribution.
from axis to appfuse
· EchoHeaders.jws
· happyaxis.jsp
· i18nLib.jsp
· indexAxis.jsp (rename index.jsp to indexAxis.jsp in axis)
from axis\WEB-INF\classes to appfuse\WEB-INF\classes
· i18n.properties
· i18n_ja.properties
You can check the screen here.
2. Run ant clean deploy tasks
3. Start tomcat and point to http://localhost:8080/appfuse/indexAxis.jsp
If all ok, you should see the image here.
Summary
You could click the Validation hyperlink to check if axis runs well?
Or Clikc List hyperlink to see deployed webservice.
Without server-config.xml, axis default deployed AdminService and Version Service
Now congraturation, you have a happy axis!! <shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"></shapetype> <stroke joinstyle="miter"></stroke><formulas></formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f><lock v:ext="edit" aspectratio="t"></lock><shape id="_x0000_i1039" style="WIDTH: 14.25pt; HEIGHT: 14.25pt" type="#_x0000_t75" alt=""></shape><imagedata src="file:///C:\DOCUME~1\baizheng\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" o:href="http://spaces.msn.com/rte/emoticons/smile_teeth.gif"></imagedata>
You could check this screen that's a happy axis.
Note: SOAPMonitor hyperlink would not work :),
If you need it, just copy *.class under axis\WEB-INF\classes to appuse root directory
More
In part2, we will show port webservice from affpsue service layer.