




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 WebLogic环境下WebService开发过程一 WebService开发环境的创建1创建WebService工程开发工具采用WebLogic自带的Wokshop开发1 / 202.引入WebLogic下的webservices.jar包该jar包位于WebLogic的安装路径下的weblogic92serverlib目录,比如D:beaweblogic92serverlib3.创建WebService类3.1创建类3.2需要发布成WebService的类引入WebService的对应类import javax.jws.*;import weblogic.jws.WLHttpTransp
2、ort;import weblogic.jws.WSDL;import javax.jws.soap.SOAPBinding;import space.QName;import javax.xml.rpc.soap.SOAPFaultException;import javax.xml.soap.Detail;import javax.xml.soap.Name;import javax.xml.soap.SOAPException;import javax.xml.soap.SOAPFactory;3.3 通过添加注释将类及方法暴露为WebService接口Web
3、Service 和WebMethod这两个标示是必须的(1)添加类注释,比如:WebService(name = "CrudTable", serviceName = "CrudTableService", targetNamespace = "")WLHttpTransport(serviceUri = "CrudTableService", portName = "CrudTableSoapPort")WSDL(exposed = true)SOAPBinding(style = SOAPB
4、inding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL)(2)添加方法注释,比如:WebMethodWebResult(name = "crudDataFromTableResponse", targetNamespace = "")4.开发环境下WebLogic服务器的配置4.1服务器视图4.2服务器配置4.3开发环境下的发布点击”发布”菜单找到对应的WSDL文件,在build/jws/weboutput/WEB-INF/目录下,比如CrudTableService.wsdl找到最下面的WSDL发布UR
5、L,比如http:/localhost:7001/TableCrud/CrudTableService,然后在浏览器地址栏输入对应的地址如http:/localhost:7001/TableCrud/CrudTableService?WSDL如能看到内容,则说明发布成功5.WebService的打WAR包方法和普通Web工程没啥区别二 WebService客户端开发环境的创建客户端需要创建一个普通的java工程就可,需要用Ant生成客户端代理程序。1. 相关用户库的创建创建用户库WebServiceClient,步骤点击“窗口”首选项”java”->”构建路径”“用户库”将weblogi
6、c.jar、webserviceclient.jar、apachexmlbeansutil.jar 加入到WebServiceClient用户库中2. 引入WebServiceClient用户库3. Ant类库的配置Ant 的主路径加入weblogic.jar点击“窗口”首选项”Ant”->“运行时“”类路径”Ant主目录条目“”添加外部JAR“4. Ant的bulid.xml的配置内容如下:<?xml version="1.0" encoding="ISO-8859-1"?><project name="SwAClie
7、nt" default="all" basedir="."> <!- set global properties for this build -><property file="./perties" /> <property name="src.dir"value="./src"/><property name="weblogic.home"value="D:/bea/weblogi
8、c92" /><property name="generated.src.dir"value="./gen_src"/><property name="classes.dir"value="./bin" /><property name="docs.dir"value="./docs" /><property name="javadoc.dir"value="$docs.dir/javad
9、oc" /><!- The application context on the server where this proxy service is deployed -><property name="context.path" value="CrudTableService" /><property name=""value="CrudTableService"/><property name="webservi
10、ce.wsdl.url"value="http:/localhost:7001/TableCrud/CrudTableService?WSDL"/><property name="" value="vs.crudClient.saaj" /><!- -><!- Standard WebLogic ANT tasks -><taskdef name="jwsc" classname="weblogic.wsee.tools.a
11、nttasks.JwscTask" /><taskdef name="clientgen" classname="weblogic.wsee.tools.anttasks.ClientGenTask" /><taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy"/><!-= Path Section=-><path id="javabuild.cla
12、ss.path"> <pathelement path="$classes.dir"/> <fileset dir="$weblogic.home/server/lib"> <include name="weblogic.jar"/> <include name="webserviceclient.jar"/> <include name="xbean.jar"/> </fileset></path&g
13、t;<path id="jwsbuild.class.path"><fileset dir="$weblogic.home/server/lib"><include name="weblogic.jar" /><include name="xbean.jar" /></fileset><fileset dir="$jdk5.home/lib"><include name="tools.jar" /&
14、gt;</fileset></path><path id="clientrun.class.path"> <pathelement path="$classes.dir"/><pathelement path="$generated.src.dir"/> <fileset dir="$weblogic.home/server/lib"> <include name="weblogic.jar"/> <inc
15、lude name="webserviceclient.jar"/> </fileset></path><target name="all" depends="clean,generate,build,run" description="Build and run the SAAJ client"/><target name="build" description="=> Build the SAAJ Client Files.&q
16、uot;><!- Compile the generated Java source first -><echo>Compile the generated client utility files.</echo><javac srcdir="$generated.src.dir" destdir="$classes.dir" includes="*/*.java" debug="on" classpathref="javabuild.class.path&
17、quot;/><!- Compile the client source file -><echo>Compile the client source file.</echo> <javac srcdir="$src.dir" destdir="$classes.dir" includes="*/*Client.java" debug="on" classpathref="javabuild.class.path"/> <!- END:
18、 Generate and compile Web Services client classes -></target><target name="generate" description="Generates the AsyncRRClientService client. Be sure the web service is running before you execute this task."> <!- BEGIN: Generate and compile Web Services client cl
19、asses -><echo>Generating the client code</echo> <clientgen wsdl="$webservice.wsdl.url" destDir="$generated.src.dir" packageName="$" /></target> <target name="clean" description="Removes all generated files"&g
20、t; <delete dir="$javadoc.dir" failonerror="false"/> <delete dir="$classes.dir" failonerror="false"/> <delete dir="$generated.src.dir" failonerror="false"/> <mkdir dir="$classes.dir" /> <mkdir dir="$
21、generated.src.dir" /> </target> <target name="run" description="Run the client test program"> <java fork="yes" classname="$.DasEsbServiceClient" failonerror="true"> <classpath refid="clientrun.class.path"/> </java> </target></project>图中红色部分需要根据具体情况进行修改5. 运行Ant的bulid.xml生成客户端存根类6. 编写客户端Java类并进行测试如:package test;import java.rm
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025设备租赁合同的市场分析
- VB编程工具使用试题及答案总结
- 项目合作协议范文
- 主管在危机沟通中的角色研究计划
- 网络连接优化策略试题及答案
- 数据库系统构架与应用考题及答案
- 提升工作灵活性的手段计划
- 2025关于陶瓷地砖销售合同书
- 行政法与经济法的交集试题及答案
- 行政管理与公共服务关系探讨试题及答案
- 自动生成的文档-2025040814-11
- (二模)济宁市2025年4月高三高考模拟考试生物试卷(含答案)
- DB32T 4772-2024自然资源基础调查技术规程
- 膝关节韧带损伤术后护理
- 雕像制作合同协议
- 2025年全国燃气安全生产管理主要负责人考试笔试试题(500题)附答案
- 列那狐测试题及答案
- 《酉阳杂俎》女性角色研究
- 浙江省嘉兴市2025届高三下学期4月教学测试物理+答案
- 婴幼儿照护 课件 2遗尿现象的干预
- 2025年广东省深圳市31校中考一模历史试题及答案
评论
0/150
提交评论