<o:p> </o:p>接手的项目用到了基于stateless session bean 的webservice,以前没有怎么接触过ws.整理一下自己的学习资料:<o:p>
</o:p>
• Quick introduction Webservice<o:p></o:p>
HTTP is supported by all Internet browsers and servers. Firewalls and proxy servers will not block this kind of traffic.<o:p>
</o:p>
1.Soap:Simple Object Access Protocol
2.WSDL:Web Services Description Language
3.UDDI :Universal Description, Discovery, and Integration<o:p>
</o:p>
应用场合: Reusable application components or connect existing software<o:p>
</o:p>
目前比较流行的两个Framework:<o:p></o:p>
1. Axis is a an implementation of the SOAP. JBoss 4.0.3 and lower are based on axis.<o:p></o:p>
2. xfire is a next-generation java SOAP framework. Feature: POJO, high performance, spring integration<o:p>
</o:p>
• SLSB exposed to WS<o:p>
</o:p>
在In J2EE1.4和EJB2.1规范中为SLSB增加了一种接口: service endpoint interface (SEI).<o:p></o:p>
ejb-jar.xml如下:
<session> </session>
<o:p>
</o:p>
一般在J2EE1.4平台上开发时,需要有四个xml文件,分别是:<o:p></o:p>
ejb-jar.xml;
wsdl;
mapping.xml主要用来定义在soap中使用的数据类型定义;
webservice.xml主要定义slsb所使用的mapping文件和wsdl.<o:p>
</o:p>
可以使用JAX-RPC开发包生成所需要的mapping.xml和wsdl文件,该开发包被包括在jwsdp中可在SUN的网站上下载。目前是支持JDK1.5的JAX-WS.<o:p>
</o:p>
基于SLSB的webservice的开发真个麻烦呀,又是remote又是bean的,写build.xml时就花了好长时间。不过还好网上有例子,用xdoclet结合axis1.x的java2wsdl命令以及<o:p></o:p>
jwsdb的wscompile命令基本可以搞定。<o:p>
</o:p>
听说EJB3.0遵循JSR181的annotations,呵呵,那样stateless session bean就可以非常方便的发布为WS了,还不用强制remote <o:p>
</o:p>
build.xml部分:
<target name="wsdeploy" depends="wsee"><exec executable="F:/Sun/jwsdp-1.5/jaxrpc/bin/wscompile.bat"><arg line="-verbose"><arg line="-cp ${buildDir}"><arg line="-gen:server"><arg line="-nd ${buildDir}/META-INF/wsdl"><arg line="-d ${srcDir}"><arg line="-mapping ${buildDir}/META-INF/jaxrpc-mapping.xml"> </arg></arg></arg></arg></arg></arg></exec></target>
ejbdoclet> target> <target name="wsee">
<taskdef classpathref="xdoclet.classpath" classname="xdoclet.modules.wsee.WseeDocletTask"
name="wseedoclet" /> <wseedoclet jaxrpcMappingFile="mappings.xml" wsdlFile="HelloWorldService.wsdl"
destDir="${buildDir}" force="true" verbose="true"> <fileset dir="${srcDir}" includes="**/HelloWorldBean.java" /> <deploymentdescriptor> <configParam name="Name" value="HelloWorldAxisService" /> deploymentdescriptor> wseedoclet> <replace file="${buildDir}/webservices.xml" token="WEB-INF/HelloWorldService.wsdl"
value="META-INF/wsdl/HelloWorldService.wsdl" /> <replace file="${buildDir}/webservices.xml" token="WEB-INF/mappings.xml" value="META-INF/jaxrpc-mapping.xml" /> target> <target name="wsdeploy" depends="wsee"> <exec executable="F:/Sun/jwsdp-1.5/jaxrpc/bin/wscompile.bat"> <arg line="-verbose" /> <arg line="-cp ${buildDir}" /> <arg line="-gen:server" /> <arg line="-nd ${buildDir}/META-INF/wsdl" /> <arg line="-d ${srcDir}" /> <arg line="-mapping ${buildDir}/META-INF/jaxrpc-mapping.xml" /> <arg line="${srcDir}/resource/wsconfig.xml" /> exec> target>
<o:p></o:p>