webservice基础知识与学习心得.doc_第1页
webservice基础知识与学习心得.doc_第2页
webservice基础知识与学习心得.doc_第3页
webservice基础知识与学习心得.doc_第4页
webservice基础知识与学习心得.doc_第5页
已阅读5页,还剩5页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Webservice基础知识常见术语WSDLWSDL即Web Services Description Language简称,是一种平台中立,语言中立并且能够在Internet上自由传输的采用XML描述的语言。OperationOperation即定义在WSDL中的方法,它包含输入消息(input message)和输出消息(output message),而消息是由一个或多个块(part)组成。块Part要么是自己定义在其他schema中的消息参数,要么是来自/2001/XMLSchemaPort typePorttype也是WSDL中的节点之一,它可以形象的理解为一个Java class,此时Operation就是Java class中的方法Binding因消息在Internet中传输的格式和协议不同,Binding是对特殊消息格式和协议的一个封装,Binding也是WSDL中的节点之一。PortPort说明Web Service部署在哪个端口,Port也是WSDL中的节点之一。Target namespaceTarget namespace可以形象理解为Java package,它没有任何意义,唯一的用途是来唯一标示Web Service,使之全局唯一EndpointEndpoint是Web Service的详细访问地址(比如:02:30000/meoms/services/EOMSBulletinUpService),它是可以访问的,而Target namespace虽然采用URL的形式命名,但是不可以访问的,一般访问会出错。Apache CXF, Apache Axis2 and Metro from SunMicrosystemsApache CXF, Apache Axis2 and Metro from SunMicrosystems只不过是针对Java的一些Web Service处理工具,作用是在客户端传递消息过来时,把它转化为服务端Java类并请调用服务端提供的服务。WSDL的两种形式RPC styleRPC即Remote Procedure Call,特点是WSDL中输入消息(input message)和输出消息(output message)定义中采用完整的参数定义,参数定义不放在其他地方。Document styleDocument style特点是WSDL中输入消息(input message)和输出消息(output message)定义可以放在其他Schema定义中,现在通常采用这种方式。Webservice开发前提:已经取得WSDL,WSDL可以自己开发,现在Eclipse有专门插件支持,可以直接拖动节点来开发即可,如果是客户端,一般对方会提供他们的WSDL,但如果自己是服务端,要么是自己定义WSDL,要么是第三方提供。以下例子都是采用AXIS开发。AXIS安装和配置安装在/dist/ws/axis/1_2_1/下载axis-bin-1_2_1.zip,解压后即安装完成。注意: 下载的axis缺少jar包:activation.jar和mail.jar,请自己加上。配置增加环境变量AXIS_HOME=C:UsersAdministratorDesktopaxis-1_2_1修改CLASSPATH,增加%AXIS_HOME%activation.jar;%AXIS_HOME%axis.jar;%AXIS_HOME%axis-ant.jar;%AXIS_HOME%commons-discovery-0.2.jar;%AXIS_HOME%commons-logging-1.0.4.jar;%AXIS_HOME%jaxrpc.jar;%AXIS_HOME%log4j-1.2.8.jar;%AXIS_HOME%mail.jar;%AXIS_HOME%saaj.jar;%AXIS_HOME%wsdl4j-1.5.1.jar;AXIS中WSDL2Java命令参数说明输入命令“ava org.apache.axis.wsdl.WSDL2Java h”,参数说明如下-h, -help print this message and exit -v, -verbose print informational messages -n, -noImports only generate code for the immediate WSDL document -O, -timeout timeout in seconds (default is 45, specify -1 to disable) -D, -Debug print debug information -W, -noWrapped turn off support for wrapped document/literal -q, -quiet do not print any informational or debug messages (except err ors) -s, -server-side emit server-side bindings for web service -S, -skeletonDeploy deploy skeleton (true) or implementation (false) in deploy.w sdd. Default is false. Assumes -server-side. -N, -NStoPkg = mapping of namespace to package -f, -fileNStoPkg file of NStoPkg mappings (default NStoPperties) -p, -package override all namespace to package mappings, use this package name instead -o, -output output directory for emitted files -d, -deployScope add scope to deploy.wsdd: Application, Request, Session -t, -testCase emit junit testcase class for web service -a, -all generate code for all elements, even unreferenced ones -T, -typeMappingVersion indicate 1.1 or 1.2. The default is 1.1 (SOAP 1.1 JAX-RPC c ompliant. 1.2 indicates SOAP 1.1 encoded.) -F, -factory name of a custom class that implements GeneratorFactory inte rface (for extending Java generation functions) -H, -helperGen emits separate Helper classes for meta data -B, -buildFile emit Ant Buildfile for web service -U, -user username to access the WSDL-URI -P, -password password to access the WSDL-URI -X, -classpath additional classpath elements -i, -nsInclude include namespace in generated code -x, -nsExclude exclude namespace from generated code -c, -implementationClassName custom name of web service implementation -u, -allowInvalidURL emit file even if WSDL endpoint URL is not a valid URL -w, -wrapArrays Prefers building beans to straight arrays for wrapped XML ar ray types (defaults to off).AXIS将WSDL转化为Java文件、客户端调用和服务端实现命令和常用参数说明命令:Java org.apache.axis.wsdl.WSDL2Java WSDL存放位置参数说明:-o 输出文件存放起始目录-d 部署服务访问范围,可选值为Application, Request, Session-s 生成服务端,无此项的话一般默认为客户端,但也可以自己实现接口使之成为服务端-S 是否生成deployd.wsdd和undeployd.wsdd文件,值为true或false-p 生成文件包名,如果不加,默认以WSDL中namespace来命名包名生成客户端命令:C:UsersAdministratorjava org.apache.axis.wsdl.WSDL2Java -p eoms.npform.eomsdispatchnpform.zobservice.client.dispatchupservice C:UsersAdministratorDesktop部省接口规范EOMSDispatchUpService.wsdl说明: -p eoms.npform.eomsdispatchnpform.zobservice.client.dispatchupservice 定义生成文件包名为eoms.npform.eomsdispatchnpform.zobservice.client.dispatchupservice生成文件如下:客户端调用服务EOMSDispatchUpService_ServiceLocator locator =new EOMSDispatchUpService_ServiceLocator();EOMSDispatchUpServiceBindingStub binding = locator.getEOMSDispatchUpService(“对方服务地址”);binding.reportAppForm(封装参数);生成服务端命令:C:UsersAdministrator java org.apache.axis.wsdl.WSDL2Java -o . -d Request -s -S true -p eoms.npform.eomsdispatchnpform.localservice.server.dispatchdownservice C:UsersAdministratorDesktop部省接口规范EOMSDispatchDownService.wsdl说明:-o . 默认输出在C:UsersAdministrator目录下面-d Request 部署时访问范围-s 生成服务端-S true 生成deployd.wsdd和undeployd.wsdd文件-p eoms.npform.eomsdispatchnpform.localservice.server.dispatchdownservice定义生成文件包名为eoms.npform.eomsdispatchnpform.localservice.server.dispatchdownservice生成文件如下:服务端代码填充一是自己实现EOMSDispatchDownServicePortType.java接口,但要修改部署文件service-config.wsdd文件中服务实现类;二是直接填充EOMSDispatchDownServiceBindingStub.java,其实此类也只不是实现了EOMSDispatchDownServicePortType.java接口而已,只是不用修改部署文件。AXIS服务部署文件拷贝拷贝解压后的axis文件axis-1_2_1axis-1_2_1webapps下面axis文件到tomcat目录Tomcat-5.5.25webapps下面;将编译后的class文件拷贝到Tomcat-5.5.25webappsaxisWEB-INFclasses目录下面;将刚才服务端生成的deploy.wsdd拷贝到Tomcat-5.5.25webappsaxisWEB-INF;启动tomcat浏览器中输入http:/localhost:8888/axis,截图如下:点击List,弹出界面如下:生成service-config.wsdd注意:tomcat一定要启,axisjar包一定要配置好命令:java org.apache.axis.client.AdminClient -l http:/localhost:8888/axis/services/EOMSDispatchDownService deploy.wsdd说明:-l http:/localhost:8888/axis/services/EOMSDisp

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论