《WebLogic环境下WebService开发过程》由会员分享,可在线阅读,更多相关《WebLogic环境下WebService开发过程(20页珍藏版)》请在金锄头文库上搜索。
1、. . . . . . WebLogic环境下WebService开发过程一 WebService开发环境的创建1创建WebService工程开发工具采用WebLogic自带的Wokshop开发2.引入WebLogic下的webservices.jar包该jar包位于WebLogic的安装路径下的weblogic92serverlib目录,比如D:beaweblogic92serverlib3.创建WebService类3.1创建类3.2需要发布成WebService的类引入WebService的对应类import javax.jws.*;import weblogic.jws.WLHttpT
2、ransport;import weblogic.jws.WSDL;import javax.jws.soap.SOAPBinding;import javax.xml.namespace.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
3、接口WebService 和WebMethod这两个标示是必须的(1)添加类注释,比如:WebService(name = CrudTable, serviceName = CrudTableService, targetNamespace = .victorysoft.)WLHttpTransport(serviceUri = CrudTableService, portName = CrudTableSoapPort)WSDL(exposed = true)SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.U
4、se.LITERAL)(2)添加方法注释,比如:WebMethodWebResult(name = crudDataFromTableResponse, targetNamespace = .victorysoft.)4.开发环境下WebLogic服务器的配置4.1服务器视图4.2服务器配置4.3开发环境下的发布点击”发布”菜单找到对应的WSDL文件,在build/jws/weboutput/WEB-INF/目录下,比如CrudTableService.wsdl找到最下面的WSDL发布URL,比如localhost:7001/TableCrud/CrudTableService,然后在浏览器地
5、址栏输入对应的地址如localhost:7001/TableCrud/CrudTableService?WSDL如能看到容,则说明发布成功5.WebService的打WAR包方法和普通Web工程没啥区别二 WebService客户端开发环境的创建客户端需要创建一个普通的java工程就可,需要用Ant生成客户端代理程序。1. 相关用户库的创建创建用户库WebServiceClient,步骤点击“窗口”首选项”java”-”构建路径”“用户库”将weblogic.jar、webserviceclient.jar、apachexmlbeansutil.jar 加入到WebServiceClient用户库中2. 引入WebServiceClient用户库3. Ant类库的配置Ant 的主路径加入weblogic.jar点击“窗口”首选项”Ant”-“运行时“”类路径”Ant主目录条目“”添加外部JAR“4. Ant的bulid.xml的配置容如下: Build the SAAJ Client Files.Compile the generated client utility files.Compile the client source file.