十一 04

生成或取得WSDL文件

Java2WSDL是Axis提供的利用Java类文件得到WSDL文件的工具。类文件可以使用接口文件编译生成,例如下面的接口文件SoftwarePrice.java。

package samples.userguide.example6;
/**
* Interface describing a web service to set and get software prices.
**/
public interface SoftwarePrice {
   public void setWidgetPrice(String softWareName, String price);
   public String getWidgetPrice(String softWareName);

编译SoftwarePrice.java。

javac SoftwarePrice.java

将SoftwarePrice.class复制到正确的package路径下。

执行下面的命令:

java org.apache.axis.wsdl.Java2WSDL -o sp.wsdl  -l"http://test.com:80/services/SoftwarePrice" -n "urn:SoftwarePrice"
-p"samples.userguide.example6" "urn:Example6" samples.userguide.example6.SoftwarePrice

更多详细内容 »

Tags: ,

作者:Jock

十一 04

Axis是以Servlet的方式运行的,而Resin的作用相当于Servlets容器(Container),因此只要配置得当,就可以使Axis在Resin环境中运行,这一点也适用于Resin以外的其它应用服务器。在Resin中配置Axis的方法如下。

将axis-1_1/webapps/axis/WEB-INF/web.xml中的Servlet配置项复制到resin.conf中对应的Web应用程序配置中。通常应包括以下内容。

<!– Axis Web-Service Configuration Start –>
 <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> 更多详细内容 »

Tags: ,

作者:Jock

十一 04

问题描述

使用http://test.com/axis查看已部署的服务时出现Axis内部错,显示有关WSDD配置的异常信息。如果把WEB-INF目录下的server-config.wsdd删除,再查看就正常了,但只能看到AdminService和Version两个系统缺省的服务,后来部署的服务都看不到了。

原因分析

Axis会在WEB应用程序的WEB-INF/目录下自动生成一个名字为server-config.wsdd的xml文件,其中记录了已部署的WEB服务。每部署一个新的WEB服务时,Axis都会将新服务的描述信息加入到server-config.wsdd中。

故障站点使用的XmlParser是resin内置的XmlParser,Axis并未对其对进行过兼容性测试,查看WEB服务信息时需要从server-config.wsdd(这是一个xml文件)取得已部署的WEB服务描述信息,当server-config.wsdd的内容较复杂时,resin内置的XmlParser因某种原因出现异常,导致Axis内部错误。Server-config.wsdd中记录的Web服务描述信息较少时不会出现异常。

解决方法

修改resin.conf,将resin的XmlParser置换为Xerces的XmlParser。


小结

如果Axis报告的错误中有关于xml解析器的错误,建议读者参照本小节描述的方法更换应用服务器的xml解析器,将会有助于问题的解决。

Tags: ,

作者:Jock

十一 04

XML解析器选用不当,经常会导致使用Apache Axis时出现一些莫名其妙的问题。

由于Apache Axis 并未对Resin内置的xml解析器进行过测试,因此推荐读者使用已通过测试的Xerces xml解析器。可以从 http://xml.apache.org/xalan-j/index.html 处下载Xalan的Java版XSLT处理器,其中包含了Xerces的Java版XML解析器,不需要再单独下载xml解析器。

Xalan 2.5.1解包后,将bin/目录下的xercesImpl.jar、xml-apis.jar和xalan.jar复制到resin安装目录的lib/目录下,例如/usr/local/resin/lib。

编辑/etc/目录下的profile文件,找到设置CLASSPATH环境变量的位置,在其后加入下面的内容(B shell)。



XMLPARSER=$RESIN_HOME/lib/xalan.jar:$RESIN_HOME/lib/xercesImpl.jar:$RESIN_HOME/lib/xml-apis.jar
export CLASSPATH=$XMLPARSER:$CLASSPATH



注意事项
如果CLASSPATH中包含其它的XML解析器设置,应将其从CLASSPATH环境变量的设置中去掉,以免发生冲突。

通过修改resin.conf将resin的XmlParser置换为Xerces的XmlParser。在resin.conf对应的Web应用程序配置中加入以下设置。



<system-property javax.xml.transform.TransformerFactory="org.apache.xalan.processor.TransformerFactoryImpl"/>
<system-property javax.xml.parsers.DocumentBuilderFactory="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>
<system-property javax.xml.parsers.SAXParserFactory="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>
<system-property org.xml.sax.driver="org.apache.xerces.parsers.SAXParser"/>



配置完成后重新启动Resin。

Tags: ,

作者:Jock

十一 04

Resin的安装就不再多说了,安装完resin后,
把axis-1_4\webapps\axis目录下的文件都拷贝到resin-3.0.21\webapps\ROOT
目录下,启动resin,报了个错,
[01:07:14.652] WEB-INF/web.xml:90: 'id' is an unknown property of 'com.caucho.s
rver.webapp.WelcomeFileList'.

一看是无关紧要的webcomefilelist直接删掉web.xml里的那一段" id="WelcomeFileList""
刷新一下,终于见到了可爱的欢迎页面。
Hello! Welcome to Apache-Axis.
What do you want to do today?


Validation – Validate the local installation's configuration

点击Validation 报了个警告信息,
Warning: could not find class org.apache.xml.security.Init from file xmlsec.jar
XML Security is not supported.

See http://xml.apache.org/security/

去提示的网站下载了xmlsec-1.3.0.jar丢到resin的lib目录下,重起resin,看起来一切ok了,基本算是安装完成,开始学习之路。。。

btw:貌似看网上有人说resin的xml解析器跟axis之间可能有点问题。

Tags: ,

作者:Jock

十一 04

Introduction
Apache Axis is an implementation of the SOAP (“Simple Object Access Protocol”) submission to W3C.

From the draft W3C specification:

SOAP is a lightweight protocol for exchanging structured information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses.

This project is a follow-on to the Apache SOAP project.

Please see the Reference Library for a list of technical resources that should prove useful.

Tags:

作者:Jock

Switch to our mobile site